Results for “SQL Server”
Small, practical examples. Search by task or narrow things down below.
Accept either of two conditions
SQL Server: Use OR to keep matching names or out-of-stock rows.
SQL Server✓ Tested
Add an optional field to an existing table
SQL Server: A nullable column permits existing rows to remain valid while data is filled later.
SQL Server✓ Tested
Add values across several rows
SQL Server: Use SUM to calculate a total quantity.
SQL Server✓ Tested
Apply a default when an insert omits a column
SQL Server: A default supplies an omitted value; an explicit NULL still follows the column’s nullability rules.
SQL Server✓ Tested
Attach an overall count to every row
SQL Server: An uncorrelated scalar subquery supplies the same aggregate to each output row.
SQL Server✓ Tested
Block deletion of a referenced parent
SQL Server: The default foreign-key action prevents deletion while a child still refers to the parent.
SQL Server✓ Tested
Build a query from several named stages
SQL Server: Separate row selection from aggregation using two common table expressions.
SQL Server✓ Tested
Calculate a cumulative integer percentage
SQL Server: Divide a running window sum by the complete total using a unique ordering key.
SQL Server✓ Tested
Calculate a total for each group
SQL Server: Group nonmissing categories and calculate separate totals.
SQL Server✓ Tested
Calculate a value with SELECT
SQL Server: Evaluate a small arithmetic expression on the database server.
SQL Server✓ Tested
Calculate each group’s integer percentage of the total
SQL Server: Multiply before division and protect against a zero denominator.
SQL Server✓ Tested
Calculate each group’s numeric spread
SQL Server: Subtract MIN from MAX to report the difference between extremes.
SQL Server✓ Tested