Tag archive
Commands grouped around the same concept, pattern, or recurring problem.
Use `EXISTS` when you only need to test whether a related row exists, not return one output row per match.
`UNION` removes duplicates, while `UNION ALL` keeps them. Picking the wrong one silently changes row counts.
Put right-table filters in the `ON` clause when you want to keep unmatched left-side rows.
Create stable run groups without a primary key by subtracting two `ROW_NUMBER()` calculations over the same ordered events.
`COUNT(column)` skips `NULL` values, while `COUNT(*)` counts every row that made it into the result set.
A row limit without an explicit sort can return different rows over time or across engines.
Filter `NULL` values out of the right side before using `NOT IN`, or the predicate can exclude everything.
`WHERE` filters individual rows before grouping. `HAVING` filters grouped results after aggregates are computed.