Ravindra BagaleCourses & study guides मराठी Track your progress

Ravi Sir's Cyber Security Cards › Revision Cards

Aggregate Functions, GROUP BY and HAVING

Aggregate Functions, GROUP BY and HAVING Aggregate functions sum up many rows: COUNT, SUM, AVG, MIN, MAX. GROUP BY makes groups. HAVING filters groups. FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. WHERE COUNT(*) > 1 gives an error. WHERE runs before grouping. Use HAVING COUNT(*) > 1

Aggregate Functions, GROUP BY and HAVING Aggregate functions sum up many rows: COUNT, SUM, AVG, MIN, MAX. GROUP BY makes groups. HAVING filters groups. FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT. WHERE COUNT(*) > 1 gives an error. WHERE runs before grouping. Use HAVING COUNT(*) > 1
Aggregate Functions, GROUP BY and HAVING · Download PNG
Read card text

What this card says

What it is

Aggregate functions sum up many rows: COUNT, SUM, AVG, MIN, MAX.

GROUP BY makes groups. HAVING filters groups.

Order of steps

FROM → WHERE → GROUP BY → HAVING → SELECT → ORDER BY → LIMIT.

Common mistake

WHERE COUNT(*) > 1 gives an error. WHERE runs before grouping.

Use HAVING COUNT(*) > 1.

ClauseFiltersCan use aggregates?
WHEREIndividual rows, before groupingNo
HAVINGGroups, after groupingYes

Learn more in the lesson: 10.8 Aggregate Functions, GROUP BY and HAVING

See all Ravi Sir's Cyber Security Cards