GROUP BY

0001-01-01

What is an SQL Aggregate?

It’s the reduce half of map/reduce: an aggregate computes a single result per group, and GROUP BY defines the groups.

0001-01-01

GROUP BY and HAVING: Thinking in Groups

GROUP BY compresses many rows into one per group. Understanding the evaluation order — WHERE, then GROUP BY, then HAVING, then SELECT — is what makes aggregation queries predictable.

0001-01-01

The FILTER Clause: Multiple Counts in One Pass

count(*) FILTER (WHERE condition) computes conditional aggregates without CASE expressions or separate subqueries — one scan, multiple results.