Becoming a Data Scientist on YouTube · Open on YouTube
Foundations: spreadsheets, data literacy and first SQL · Novice · Lesson 14 of 99 · 6 min video, then about 5 hours of practice
SQL aggregation: GROUP BY, HAVING and counting correctly
After this you can summarise data by groups with COUNT, SUM, AVG, MIN and MAX, filter groups with HAVING, and know when to use COUNT(DISTINCT).
Why it matters
Most business questions are aggregations: revenue by month, customers by region, orders per customer. Learn the difference between WHERE (filters rows before grouping) and HAVING (filters groups after), and the difference between COUNT(*), COUNT(column) and COUNT(DISTINCT column). The trap is aggregating after a join that duplicated rows; always aggregate at the grain you mean.
How to use this resource
A focused six-minute explanation of GROUP BY and the WHERE versus HAVING distinction.