SQL #05 — GROUP BY, HAVING, SUM, COUNT, AVG — Aggregate Functions Explained
hosiyar
0:00 / 0:00
SQL #05 — GROUP BY, HAVING, SUM, COUNT, AVG — Aggregate Functions Explained
288 просмотров · 1 мес. назад
hosiyar
885 подписчиков
288 просмотров · 1 мес. назад
So far, every query we've written has given us individual rows — one row per employee, one row per student. But what if you want the big picture? Total salary by department. Average marks per subject. Number of employees in each city.
That's what aggregate functions and GROUP BY are for. This lesson takes you from raw individual rows to meaningful summaries — and then we tackle the one question that trips up almost everyone: what's the difference between WHERE and HAVING?
We also cover something most SQL tutorials never explain — the actual order in which SQL executes your query behind the scenes. Once you see that, GROUP BY vs WHERE vs HAVING stops being confusing forever.
What you'll learn:
Aggregate functions — COUNT, SUM, AVG, MIN, MAX
GROUP BY — summarizing data by categories
HAVING — filtering groups after aggregation
WHERE vs HAVING — when to use which, and why
SQL query execution order — FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT
How knowing the execution order makes every query easier to write
We use the same practice database from lesson #01. If you haven't set it up, start there.
📁 Practice SQL file & resources: https://github.com/deep473/hosiyar-re...
This is lesson #05 of the full "SQL Zero to Advanced" course. Lessons build on each other — if you haven't watched #04 (Functions & CASE WHEN), watch that first.
🔗 Full SQL course playlist: • SQL Full Course — From Zero to Advanced, S...
#SQL #MySQL #GroupBy #SQLAggregates #SQLForBeginners #LearnSQL