Tag archive
Commands grouped around the same concept, pattern, or recurring problem.
Use `CASE WHEN` inside `SUM` or `COUNT` to produce multiple metrics from a single pass over grouped data.
Collect values from multiple rows into a single JSON array, ordered and grouped by other columns.
Aggregate multiple string values from grouped rows into a single delimited string.
Use `HAVING` to filter aggregate results after `GROUP BY`, the same way `WHERE` filters individual rows before grouping.
Group rows by the candidate key and keep only values that appear more than once.
Aggregate rows by category with `GROUP BY` and count how many rows fall into each group.
Bucket dates into month starts, then aggregate counts or totals per month.
Use more than one column in `GROUP BY` when each combination defines a separate aggregate bucket.
`WHERE` filters individual rows before grouping. `HAVING` filters grouped results after aggregates are computed.