Sub-query returning a single value
A sub-query in brackets returns one value, like the average. The outer WHERE compares each row's field to it. MIN or MAX work too.
Understanding Sub-query returning a single value in QCE Digital Solutions Unit 2
What it does: MIN inside the brackets returns the single smallest points value, and the outer WHERE finds the student who has that value. The sub-query must be wrapped in brackets. Without them the query is a syntax error. Because the sub-query gives a single value, comparison operators like > , < and = work. GROUP BY is not needed. The inner query in brackets is worked out first. It gives one average price, then the outer query compares each product's price to it.
Common mistakes: There is a trailing comma after points, so SQL expects another field before FROM. Remove it: SELECT firstName, points. The WHERE clause has no comparison operator, so it cannot compare price with the single value from the sub-query. It should be WHERE price <.
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
WHERE mark > (SELECT AVG(mark) FROM results)Fill in the Blanks
Spot the Error
Student with a class code? Join your class →