REVISION GUIDE · IGCSE 0478 AND A LEVEL 9618
Common SQL mistakes in IGCSE and A Level Computer Science
The SQL each course expects, a worked output question, an A Level join with GROUP BY, and the slips that cost easy marks in Cambridge exams.
SQL questions look short, but they are some of the easiest marks to lose in Cambridge IGCSE Computer Science (0478) Paper 2 and AS and A Level Computer Science (9618) Paper 1. One wrong operator, a missing DESC or an extra field in the output and a “simple” two-mark answer becomes zero. This guide shows the SQL you need for each course, works through new examples on one small table, and lists the mistakes examiners see most often.
SELECT, WHERE and ORDER BY.1. What SQL each course expects
IGCSE only asks you to read, complete and write queries on a single table. A Level adds more keywords, joins two tables, and expects you to define and change tables too.
| Course | Keywords you must know | Typical tasks |
|---|---|---|
| IGCSE 0478 | SELECT, FROM, WHERE, ORDER BY, SUM, COUNT | Complete a query, write a query, give the output of a query (one table only) |
| AS and A Level 9618 (DML) | All of the above plus GROUP BY, INNER JOIN, AVG, INSERT INTO, UPDATE, DELETE FROM | Queries across two tables, totals per group, adding and changing records |
| AS and A Level 9618 (DDL) | CREATE DATABASE, CREATE TABLE, ALTER TABLE, PRIMARY KEY, FOREIGN KEY … REFERENCES | Create a table with suitable data types and keys |
See the full notes on the IGCSE databases unit and the A Level databases unit.
2. The example table
Every example below uses this table, GAME, from a small games shop. GameID is the primary key.
| GameID | Title | Genre | Price | Players | InStock |
|---|---|---|---|---|---|
| G01 | Star Rally | Racing | 24.99 | 2 | TRUE |
| G02 | Moss Quest | Puzzle | 9.50 | 1 | TRUE |
| G03 | Iron Tide | Strategy | 32.00 | 4 | FALSE |
| G04 | Pixel Chef | Puzzle | 14.99 | 2 | TRUE |
| G05 | Night Lap | Racing | 19.99 | 1 | FALSE |
| G06 | Castle Code | Strategy | 27.50 | 2 | TRUE |
3. Worked example: giving the output of a query
“State the output” questions test whether you can apply the query exactly, row by row. Take this query:
SELECT Title, Price FROM GAME WHERE Genre = 'Puzzle' OR Price > 25 ORDER BY Price DESC;
Work through it in this order:
- WHERE first: test every row. Moss Quest and Pixel Chef are Puzzle games. Iron Tide (32.00) and Castle Code (27.50) cost more than 25. Star Rally (24.99) and Night Lap fail both tests.
- ORDER BY next: sort the four rows by Price, highest first.
- SELECT last: show only Title and Price, in that order.
| Title | Price |
|---|---|
| Iron Tide | 32.00 |
| Castle Code | 27.50 |
| Pixel Chef | 14.99 |
| Moss Quest | 9.50 |
Two more quick ones on the same table: SELECT COUNT(*) FROM GAME WHERE InStock = TRUE; outputs 4, and SELECT SUM(Price) FROM GAME WHERE Genre = 'Racing'; outputs 44.98 (24.99 + 19.99).
4. A Level example: GROUP BY and INNER JOIN
Suppose a second table, ORDERS(OrderID, GameID, Quantity), has GameID as a foreign key linking to GAME. It holds five orders: G01 × 3, G04 × 1, G01 × 2, G06 × 5 and G02 × 4. To show the total quantity ordered for each game:
SELECT GAME.Title, SUM(ORDERS.Quantity) FROM GAME INNER JOIN ORDERS ON GAME.GameID = ORDERS.GameID GROUP BY GAME.Title ORDER BY GAME.Title;
Output: Castle Code 5, Moss Quest 4, Pixel Chef 1, Star Rally 5. Games with no orders (Iron Tide and Night Lap) do not appear, because an inner join only returns rows that match in both tables. Notice the Table.Field names: GameID exists in both tables, so you must say which one you mean.
5. Mistakes that cost marks
- Using AND when you mean OR.
WHERE Genre = 'Puzzle' AND Genre = 'Racing'returns nothing, because one field cannot hold two values at once. “Puzzle and racing games” in English meansORin SQL. - Getting the boundary wrong. “At least 24.99” is
>= 24.99, which includes Star Rally.> 24.99leaves it out. Check words like “over”, “under”, “at least” and “no more than”. - Mixing up COUNT and SUM. COUNT gives how many rows; SUM adds up the values in a numeric field. “How many games” is COUNT; “the total price” is SUM.
- Forgetting DESC.
ORDER BYsorts in ascending order unless you writeDESC. “Most expensive first” or “highest first” always needs it. - Showing extra or missing fields. Only list the fields the question asks for, in the order it asks for them.
SELECT *is rarely what the mark scheme wants. - Quotes in the wrong place. Put text values in quotes (
'Puzzle'), but not numbers (Price > 25) or field names. Booleans are written as TRUE or FALSE. - Using program operators. SQL uses
=for “equals” and<>for “not equal to”, not==or!=. - Output questions: adding rows that do not match. Test every row against the full condition before you sort. Write the output as a small table with the field names as headings.
- A Level: missing GROUP BY. If you SELECT a normal field together with SUM, COUNT or AVG, you need
GROUP BYon that field. - A Level: a join without a condition.
INNER JOINneedsONwith the primary key = foreign key match. - A Level: UPDATE or DELETE without WHERE.
UPDATE GAME SET Price = 20.00;changes every row. Always say which record, for exampleWHERE GameID = 'G05'.
6. A Level DDL: creating a table correctly
When asked to write a CREATE TABLE statement, give each field a sensible data type and state the keys. For the ORDERS table:
CREATE TABLE ORDERS ( OrderID VARCHAR(6), GameID VARCHAR(3), Quantity INTEGER, PRIMARY KEY (OrderID), FOREIGN KEY (GameID) REFERENCES GAME(GameID) );
Common slips here are using INTEGER for IDs that contain letters, using REAL for whole-number counts, and forgetting REFERENCES with the linked table and field. To change an existing table, use ALTER TABLE, for example ALTER TABLE GAME ADD Rating INTEGER;.
7. How to practise
Reading SQL is not enough: write queries and run them. Try the SQL practice playground, then cover the output and predict it before you press run. When a question says “write” or “complete”, check the meaning of the command word in our command words guide.
Frequently asked questions
Do I need a semicolon at the end of an SQL statement?
It is good practice and you should include it, but examiners mark the SQL itself. A missing semicolon is not usually what loses the mark.
Does IGCSE Computer Science include INNER JOIN or GROUP BY?
No. The IGCSE 0478 syllabus covers single-table queries with SELECT, FROM, WHERE, ORDER BY, SUM and COUNT. Joins, GROUP BY and AVG are part of AS and A Level 9618.
Should I use single or double quotes for text in SQL?
Single quotes are standard SQL and are the safest choice. Be consistent, and never put quotes around numbers or field names.
Want help with database questions? In a 1-to-1 lesson we can practise SQL queries and output questions together. Book a free demo →