FIND YOUR NEXT FEW LINES

The snippet library.

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

125 snippets foundClear filters
SQLiteGetting Started

Remove duplicate result values

SQLite: Use DISTINCT when repeated category values are not useful.

SQLite✓ Tested
SQLiteBulk changes & set operations

Remove duplicate values while keeping the smallest key

SQLite: Identify retained keys in a grouped subquery before deleting other copies.

SQLite✓ Tested
SQLiteText cleanup & matching

Remove surrounding spaces from text

SQLite: TRIM removes leading and trailing space characters by default.

SQLite✓ Tested
SQLiteWindow analytics

Repeat the first ordered value beside each row

SQLite: FIRST_VALUE reads the first value in the current window frame.

SQLite✓ Tested
SQLiteText cleanup & matching

Replace a literal substring

SQLite: REPLACE performs a literal replacement rather than a regular-expression substitution.

SQLite✓ Tested
SQLiteSubqueries & ranked selection

Report duplicate business values and their frequency

SQLite: Group by a candidate business key and retain only groups with multiple rows.

SQLite✓ Tested
SQLiteConstraints & defaults

Require a value with NOT NULL

SQLite: Declare required fields at the database boundary, not only in application validation.

SQLite✓ Tested
SQLiteGetting Started

Require two filtering conditions

SQLite: Combine category and quantity conditions with AND.

SQLite✓ Tested
SQLiteSubqueries & ranked selection

Return all rows tied for the maximum in a group

SQLite: An equality comparison with a grouped maximum retains ties rather than choosing one arbitrary row.

SQLite✓ Tested
SQLiteReporting & grouped calculations

Return zero for a sum over no rows

SQLite: SUM produces NULL for an empty input; COALESCE supplies the desired reporting default.

SQLite✓ Tested
SQLiteGetting Started

Run a first SELECT query

SQLite: Return a literal value without creating a table.

SQLite✓ Tested
SQLiteQueries & text

Search a small FTS5 table

Use SQLite’s full-text index to match a term.

FTS5✓ Tested