Aggregation & summary — flashcards
One card per lesson — 4 in this module. Recall the key points, then check. 4 cards. Click a card to flip, or use the arrow keys and space bar.
Aggregate functions — what are the key points?
COUNT(*) counts rows; COUNT(col) skips nulls · AVG divides by the non-null count · Aggregates cannot appear in WHERE — use HAVING Read the lesson
GROUP BY — what are the key points?
Every SELECT column must be grouped or aggregated · More GROUP BY columns means finer groups and more rows · Repeat the expression in GROUP BY rather than relying on alias support Read the lesson
HAVING versus WHERE — what are the key points?
WHERE filters rows before grouping; HAVING filters groups after · Row-level conditions belong in WHERE — it is cheaper · HAVING is evaluated before SELECT, so aliases may not be available Read the lesson
Conditional aggregation with CASE — what are the key points?
CASE conditions evaluate top to bottom; first match wins · COUNT(CASE WHEN ... THEN 1 END) with no ELSE counts only matches · Conditional aggregation pivots data in a single pass Read the lesson