GROUP BY correctness, GROUPING SETS, ROLLUP, CUBE, FILTER, and the multi-level CTE patterns that make complex reporting reliable.
Aggregation is where most SQL bugs live — join amplification, missing NULLs, HAVING confusion. These lessons cover how GROUP BY really works, the FILTER clause for multiple counts in one pass, and the advanced grouping features (GROUPING SETS, ROLLUP, CUBE) that replace repeated queries.
Paired course
Reliable AggregationGo deeper with structured exercises, datasets, and production patterns.
It's the reduce half of map/reduce: an aggregate computes a single result per group, and GROUP BY defines the groups.
count(*) FILTER (WHERE condition) computes conditional aggregates without CASE expressions or separate subqueries — one scan, multiple results.
Median, 90th, 95th, and 99th percentile — computed together in a single pass with an ordered-set aggregate.
Go deeper
These lessons are the foundation. The book gives you the complete treatment, with real datasets you can run and the production patterns that turn thousands of lines of code into simple queries.
Get the Book — $89