FIND YOUR NEXT FEW LINES

The snippet library.

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

125 snippets foundClear filters
SQLiteText cleanup & matching

Search for a literal LIKE wildcard

SQLite: Declare an escape character so a percent sign in the pattern is literal.

SQLite✓ Tested
SQLiteWindow analytics

Select the top row in each group with a tie-breaker

SQLite: Filter an outer query on ROW_NUMBER because window functions are not evaluated in WHERE.

SQLite✓ Tested
SQLiteGetting Started

Select values in an inclusive range

SQLite: BETWEEN includes both endpoints of the range.

SQLite✓ Tested
SQLiteJSON data

Set a JSON property

Create an updated JSON document from existing text.

json_set✓ Tested
SQLiteWindow analytics

Show a group total beside each detail row

SQLite: A partitioned aggregate preserves detail rows instead of collapsing them with GROUP BY.

SQLite✓ Tested
SQLiteSubqueries & ranked selection

Sort preferred rows ahead of other rows

SQLite: A CASE ordering key expresses business priority before a stable secondary sort.

SQLite✓ Tested
SQLiteGetting Started

Sort the highest quantities first

SQLite: Specify descending order and a stable tie breaker.

SQLite✓ Tested
SQLiteWindow analytics

Sum a row and its immediate predecessor

SQLite: A ROWS frame counts physical ordered rows rather than all peers with the same sort value.

SQLite✓ Tested
SQLiteText cleanup & matching

Treat an empty trimmed value as missing

SQLite: NULLIF converts an empty string to NULL before a fallback is applied.

SQLite✓ Tested
SQLiteGetting Started

Turn a condition into a result label

SQLite: Use CASE to describe stock availability for each row.

SQLite✓ Tested
SQLiteReporting & grouped calculations

Turn known group values into columns

SQLite: Conditional aggregation gives a portable pivot when the category set is known.

SQLite✓ Tested
SQLiteSchema design & transactions

Undo a multi-row transfer atomically

SQLite: The first transaction commits the fixtures. Rolling back the second transaction restores both sides of the attempted transfer.

SQLite✓ Tested