FIND YOUR NEXT FEW LINES

The snippet library.

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

25 snippets foundClear filters
SQLGetting Started

Accept either of two conditions

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

SQL✓ Tested
SQLGetting Started

Add values across several rows

SQL: Use SUM to calculate a total quantity.

SQL✓ Tested
SQLGetting Started

Calculate a total for each group

SQL: Group nonmissing categories and calculate separate totals.

SQL✓ Tested
SQLGetting Started

Calculate a value with SELECT

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

SQL✓ Tested
SQLGetting Started

Count the rows in a table

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

SQL✓ Tested
SQLGetting Started

Create a table and insert its first row

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

SQL✓ Tested
SQLGetting Started

Delete one row from a practice table

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

SQL✓ Tested
SQLGetting Started

Display a fallback for missing data

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

SQL✓ Tested
SQLGetting Started

Filter by a numeric comparison

SQL: Keep rows whose quantity exceeds a chosen threshold.

SQL✓ Tested
SQLGetting Started

Filter groups after aggregation

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

SQL✓ Tested
SQLGetting Started

Find missing values with IS NULL

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

SQL✓ Tested
SQLGetting Started

Give a result column a readable name

SQL: Use AS to label a computed result column.

SQL✓ Tested