FIND YOUR NEXT FEW LINES

The snippet library.

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

25 snippets foundClear filters
PostgresGetting Started

Accept either of two conditions

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

Postgres✓ Tested
PostgresGetting Started

Add values across several rows

Postgres: Use SUM to calculate a total quantity.

Postgres✓ Tested
PostgresGetting Started

Calculate a total for each group

Postgres: Group nonmissing categories and calculate separate totals.

Postgres✓ Tested
PostgresGetting Started

Calculate a value with SELECT

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

Postgres✓ Tested
PostgresGetting Started

Count the rows in a table

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

Postgres✓ Tested
PostgresGetting Started

Create a table and insert its first row

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

Postgres✓ Tested
PostgresGetting Started

Delete one row from a practice table

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

Postgres✓ Tested
PostgresGetting Started

Display a fallback for missing data

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

Postgres✓ Tested
PostgresGetting Started

Filter by a numeric comparison

Postgres: Keep rows whose quantity exceeds a chosen threshold.

Postgres✓ Tested
PostgresGetting Started

Filter groups after aggregation

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

Postgres✓ Tested
PostgresGetting Started

Find missing values with IS NULL

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

Postgres✓ Tested
PostgresGetting Started

Give a result column a readable name

Postgres: Use AS to label a computed result column.

Postgres✓ Tested