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.
Compute the arithmetic mean of numeric values across matching rows.
Aggregate multiple string values from grouped rows into a single delimited string.
Aggregate a result set into a single row that reports how many rows matched.
Count only the distinct values in a column, ignoring duplicates.
Use `HAVING` to filter aggregate results after `GROUP BY`, the same way `WHERE` filters individual rows before grouping.
Use `MIN` and `MAX` to find the lowest and highest values in a column.
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.
Add numeric values across matching rows and return one aggregate total.
`COUNT(column)` skips `NULL` values, while `COUNT(*)` counts every row that made it into the result set.