FIND YOUR NEXT FEW LINES

The snippet library.

Small, practical examples. Search by task or narrow things down below.

25 snippets foundClear filters
SQL ServerGetting Started

Accept either of two conditions

SQL Server: Use OR to keep matching names or out-of-stock rows.

SQL Server✓ Tested
SQL ServerGetting Started

Add values across several rows

SQL Server: Use SUM to calculate a total quantity.

SQL Server✓ Tested
SQL ServerGetting Started

Calculate a total for each group

SQL Server: Group nonmissing categories and calculate separate totals.

SQL Server✓ Tested
SQL ServerGetting Started

Calculate a value with SELECT

SQL Server: Evaluate a small arithmetic expression on the database server.

SQL Server✓ Tested
SQL ServerGetting Started

Count the rows in a table

SQL Server: COUNT(*) includes every row, including rows with NULL columns.

SQL Server✓ Tested
SQL ServerGetting Started

Create a table and insert its first row

SQL Server: Define column types and a primary key, then insert one row using an explicit column list.

SQL Server✓ Tested
SQL ServerGetting Started

Delete one row from a practice table

SQL Server: Restrict DELETE with a primary-key condition and verify the remaining row count.

SQL Server✓ Tested
SQL ServerGetting Started

Display a fallback for missing data

SQL Server: Return a supplied label when a column contains NULL.

SQL Server✓ Tested
SQL ServerGetting Started

Filter by a numeric comparison

SQL Server: Keep rows whose quantity exceeds a chosen threshold.

SQL Server✓ Tested
SQL ServerGetting Started

Filter groups after aggregation

SQL Server: Use HAVING to test a group’s calculated total.

SQL Server✓ Tested
SQL ServerGetting Started

Find missing values with IS NULL

SQL Server: Use IS NULL rather than equality to test for missing data.

SQL Server✓ Tested
SQL ServerGetting Started

Give a result column a readable name

SQL Server: Use AS to label a computed result column.

SQL Server✓ Tested