Results for “SQL Server”
Small, practical examples. Search by task or narrow things down below.
Update several classifications in one statement
SQLite: A CASE expression computes the new value for each row covered by the update predicate.
SQLite✓ Tested
Accept either of two conditions
Postgres: Use OR to keep matching names or out-of-stock rows.
Postgres✓ Tested
Add an interval to a date
Perform calendar arithmetic with an interval literal.
INTERVAL✓ Tested
Add an optional field to an existing table
Postgres: A nullable column permits existing rows to remain valid while data is filled later.
Postgres✓ Tested
Add days to a date
Use a date modifier for calendar arithmetic.
date✓ Tested
Add values across several rows
Postgres: Use SUM to calculate a total quantity.
Postgres✓ Tested
Apply a default when an insert omits a column
Postgres: A default supplies an omitted value; an explicit NULL still follows the column’s nullability rules.
Postgres✓ Tested
Attach an overall count to every row
Postgres: An uncorrelated scalar subquery supplies the same aggregate to each output row.
Postgres✓ Tested
Block deletion of a referenced parent
Postgres: The default foreign-key action prevents deletion while a child still refers to the parent.
Postgres✓ Tested
Build a JSON array from rows
Aggregate ordered text values into JSON.
json_group_array✓ Tested
Build a query from several named stages
Postgres: Separate row selection from aggregation using two common table expressions.
Postgres✓ Tested
Calculate a cumulative integer percentage
Postgres: Divide a running window sum by the complete total using a unique ordering key.
Postgres✓ Tested