Tag archive
Commands grouped around the same concept, pattern, or recurring problem.
Count or sum only the rows that match a specific condition without a WHERE clause — using `FILTER (WHERE ...)` in PostgreSQL and SQLite, or `CASE WHEN` inside the aggregate for other engines.
Accumulate a column's values row by row using `SUM` as a window function.
Divide the sum of value times weight by the sum of weights instead of averaging pre-aggregated values.
Use `SUM(...) OVER ()` to compare each row's value to the total without collapsing the result set.
Use `ROWS BETWEEN` in a window function to aggregate only the rows immediately surrounding each row.
Add numeric values across matching rows and return one aggregate total.