SQL HAVING
Filters groups after GROUP BY using an aggregate condition, such as HAVING COUNT(*) > 3. WHERE filters rows before grouping.
Understanding SQL HAVING in QCE Digital Solutions Unit 2
What it does: WHERE removes rows that are not in Year 7 before GROUP BY forms the groups, so it cannot use aggregates. The AVG(mark) is only known once each subject group exists, so the condition must go in HAVING after GROUP BY.
Common mistakes: GROUP BY needs the word BY. The line should be FROM students GROUP BY house so the rows are grouped before HAVING filters the groups. WHERE filters single rows before grouping, so it cannot use an aggregate like AVG(). To filter groups by their average, use HAVING AVG(points) > 100;.
Free printable worksheet with full answer key — or add this module to a class and your students practise it interactively.
This module's key terms are also in a printable crossword (Modules 305–336) and word search (Modules 234–409).
Take this worksheet further — free with Cloodit
Each concept is reinforced from every angle — learned, then applied, then tested.
Cloodit turns curriculum-aligned coding content into journeys students work through one biome at a time.
Over 100 of them, across seven natural biomes.
Turns their work into revision material ready for Flash Cards and Exam study.
Live, competitive practice for the start of the lesson or a teacher-led lesson finisher.
Honour your top performers, or encourage a student who's trying hard — ready to print in seconds.
Quick Questions
Match the Pairs
Key Term
HAVINGFill in the Blanks
Spot the Error
Student with a class code? Join your class →