Aggregation
Learn SQL aggregation with practical examples and guided drills on dbSyntax.
Start with COUNT / SUM / AVG / MIN / MAXCOUNT / SUM / AVG / MIN / MAX
BeginnerAggregate functions collapse many rows into a single number. "How many orders?" "What's the total revenue?" "What's the average basket size?...
GROUP BY
BeginnerAn aggregate without GROUP BY collapses the whole table into one row. GROUP BY splits the table into buckets first, then runs the aggregate ...
HAVING
BeginnerWHERE filters rows before aggregation. HAVING filters groups after aggregation. That is the entire distinction, and also why HAVING exists a...
CASE & Conditional Aggregation
BeginnerCASE is SQL's if/else. It's an expression, not a statement. It produces one value per row, so it can go anywhere a column can: in SELECT, in...