Zip labels with measurements by index
Two JSON arrays can be aligned by their integer indexes. An inner join will omit an unmatched tail.
Developer journal
Query techniques for reporting, reshaping records and working with JSON in SQLite.
Two JSON arrays can be aligned by their integer indexes. An inner join will omit an unmatched tail.
Set operations compare rows under SQL's rules for duplicates. Check whether the result represents membership or the number of occurrences.
Grouping timestamps by day produces counts only for days present in the data. A continuous chart may need a calendar series as well.
LAG retrieves a prior row's value within an ordered window. The first row lacks a predecessor and usually needs its own display rule.
A single-character wildcard expresses a different constraint from a variable-length wildcard. Decide whether punctuation in a search pattern is literal.
An alias defines the name visible to query consumers. It can decouple an API field from a table's internal naming.
COUNT(*) counts rows, while counting a nullable expression ignores null values. Choose the measure that matches the report.
An upsert can accumulate a new count into an existing key. The uniqueness constraint determines which row receives the update.
A running total turns individual durations into a budget trajectory. Decide whether meeting the limit counts as crossing it.
Quoting a value can help inspect how SQLite represents it as a literal. Application queries should still pass user values as bound parameters.
A JSON array preserves element order and type. Inspect the distinction between a nested JSON value and a string containing JSON text.
A gap between identifiers may reflect deletion or allocation history. Locate the gap before assigning it a business meaning.
Neighbour comparisons require a stable ordering. An ID tie or timestamp tie can change which record counts as the neighbour.
Invalid JSON can interrupt a query that expects structured input. Validate incoming text before passing it into extraction functions.
A column default applies when an insert omits that column. Supplying an explicit NULL is a separate operation.
Text sorting places character sequences in lexical order. Cast numeric text deliberately when the ordering represents a quantity.
A view gives a reusable query a stable name. Its output still reflects changes in the underlying tables.
Integer array indexes can be divided into page buckets. Sort the elements within each aggregate to preserve the source sequence.
A recursive query needs both an initial row and a terminating condition. Walk through the boundary to see whether zero is included.
Arithmetic in a select list produces a derived value without changing the stored column. Give the result a name with clear units.
An integrity check examines SQLite's internal structures. It answers a different question from whether the application's business rules hold.
Replacing a JSON array element requires an existing path. A missing coordinate calls for a separate insert or set policy.
Selecting named columns makes the result shape explicit. A later schema addition then leaves the consumer's expected fields intact.
Percentages can lose their fractional part when both operands use integer arithmetic. Introduce a real operand before dividing.
An empty string and NULL communicate different conditions. NULLIF can normalize an empty import field where the schema expects a missing value.
Unix seconds provide a compact comparison key for timestamps. The conversion still depends on a clear timezone convention for incoming text.
Lowercasing a label can simplify a display or comparison key. SQLite's built-in casing rules need particular care for non-ASCII text.
A status filter is a useful baseline for a report. Explicitly decide how unknown or null statuses should behave.
DISTINCT removes duplicate combinations across the entire selection. Adding another selected column can change what counts as unique.
A comparison with the overall average uses two levels of aggregation or a scalar subquery. Define which records belong in the baseline.