Completing an SQL script
Completing an SQL script: read the task, then fill the gap with the right field, WHERE condition, ASC or DESC, AND or OR, or SUM or COUNT so the query returns exactly what is asked.
Understanding Completing an SQL script in IGCSE Computer Science Paper 2
What it does: SUM adds up the values in a numeric field, while COUNT would only give how many records there are. OR returns a record if either condition is true. AND would only return products that meet both conditions. DESC sorts from highest to lowest. ASC sorts from lowest to highest, which is the opposite of what the task asks for. The field list after SELECT gives the columns, WHERE filters to Red house and DESC puts the biggest points value first. A WHERE clause with no condition is incomplete, so the missing condition must be filled in to match the task.
Common mistakes: The task asks for first name and points, but the query selects house. The missing field after SELECT should be points: SELECT firstName, points. Highest first means descending order. The sort direction must be DESC, not ASC.
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 525–538) and word search (Modules 500–538).
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
SELECT field FROM table WHERE condition;Fill in the Blanks
Spot the Error
Student with a class code? Join your class →