Data Analystdata analyticsintermediate3 interactive MCQs in app
SQL aggregation
WHERE vs HAVING evaluation orderCOUNT(*) vs COUNT(col) NULL behaviorGROUP BY non-aggregated column rule
Core Concept
SQL GROUP BY collapses rows sharing group keys into one summary row per group using aggregates (COUNT, SUM, AVG, MIN, MAX). Remember SQL evaluation order: WHERE filters raw rows BEFORE GROUP BY; HAVING filters grouped summary rows AFTER aggregation. Notice COUNT(*) counts all rows including NULLs, whereas COUNT(col) skips NULLs, and AVG(col) ignores NULLs cleanly.
Worked Example
to find categories with >3 paid orders totaling >=$500, filter paid rows in WHERE, GROUP BY category, then enforce COUNT(*) > 3 AND SUM(amount) >= 500 in HAVING.
Common Pitfall
putting aggregates inside WHERE (syntax error) or putting non-aggregated columns in SELECT without listing them in GROUP BY.
Recommended Readings & Practice
Practice SQL aggregation with 3 graded MCQs & written feedback.
Take SOARDO’s free 12-question diagnostic to see how strong you are across your target role and unlock adaptive daily missions.