Analytics & Joins · 8 min read · Beginner
Aggregates, GROUP BY & HAVING
Compute totals, counts, and averages across categories with COUNT(), SUM(), AVG(), GROUP BY, and HAVING.
What you'll learn
- Summarize rows with COUNT(*), SUM(), AVG(), MIN(), and MAX()
- Group rows by category using GROUP BY
- Understand the difference between WHERE (before grouping) and HAVING (after grouping)
Aggregate functions turn hundreds of raw rows into clean executive metrics.
Fill-in-the-Blank Exercise
Group & Filter Aggregates
Count learners per track and keep only tracks with at least 2 learners.
SELECT track, (*) AS learners
FROM enrollments
BY track
COUNT(*) >= 2;Try It Yourself
SQLAverage Score by Track
Query Result (In-Browser SQLite)
Click Run SQL to execute this query against a live in-browser SQLite database.
Check Your Understanding
Score: 0 / 1
1. Which clause filters grouped results after GROUP BY has been computed?
Study Workspace
Finished this lesson?
Your progress is saved locally in your browser, no account needed.