The snippet library.
Small, practical examples. Search by task or narrow things down below.
Join related rows from two tables
Postgres: Match a category key to its display label with an explicit join condition.
Postgres✓ Tested
Keep rows matching a condition
Postgres: Use WHERE to select rows with a particular category.
Postgres✓ Tested
Match a text prefix
Postgres: Use a percent wildcard after a known prefix.
Postgres✓ Tested
Match one value from a short list
Postgres: Use IN for a set of allowed values.
Postgres✓ Tested
Read named columns from a table
Postgres: Choose the columns needed and request a deterministic row order.
Postgres✓ Tested
Read the smallest and largest values
Postgres: Use MIN and MAX without sorting and fetching every row.
Postgres✓ Tested
Remove duplicate result values
Postgres: Use DISTINCT when repeated category values are not useful.
Postgres✓ Tested
Require two filtering conditions
Postgres: Combine category and quantity conditions with AND.
Postgres✓ Tested
Run a first SELECT query
Postgres: Return a literal value without creating a table.
Postgres✓ Tested
Select values in an inclusive range
Postgres: BETWEEN includes both endpoints of the range.
Postgres✓ Tested
Sort the highest quantities first
Postgres: Specify descending order and a stable tie breaker.
Postgres✓ Tested
Turn a condition into a result label
Postgres: Use CASE to describe stock availability for each row.
Postgres✓ Tested