SQL sub-selection (subquery)
A sub-selection is a SELECT inside brackets within another statement. The inner query runs first and its result is used by the outer query, such as in a WHERE condition.
Understanding SQL sub-selection (subquery) in QCE Digital Solutions Unit 3
What it does: The inner SELECT in brackets finds the highest year level, and the outer query uses that result to filter the rows. IN checks whether a value matches any value in the list the inner query returns. Comparing with > expects a single value, not a list. A sub-selection must be inside brackets: WHERE points > (SELECT AVG(points) FROM students). Select only the matching column in the subquery: (SELECT productId FROM orders).
Common mistakes: A sub-selection must be wrapped in round brackets ( ), not square brackets. It should be WHERE points > (. A trailing comma after the last field in the SELECT list is a syntax error. It should be SELECT firstName.
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 251–337) and word search (Modules 194–337).
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
WHERE points > (SELECT AVG(points) FROM students)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →