Subject guides · 7 min read

IGCSE Computer Science SQL Queries Explained (0478)

IGCSE Computer Science SQL queries (0478) explained: SELECT, WHERE, ORDER BY, SUM, COUNT, AND and OR, with six worked examples and mistakes to avoid.

IGCSE Computer Science SQL queries (0478) look intimidating the first time you see one, but the syllabus only asks for a small, predictable toolkit. Once you can read a query line by line and predict its output, most SQL marks become some of the easiest in Paper 2.

This guide covers exactly what Cambridge expects, a four-step method for reading any query, six worked examples on one practice table, and the mistakes that lose marks.

What does the 0478 syllabus actually require for SQL?

In the 2026-2028 Cambridge IGCSE Computer Science (0478) syllabus, databases sit in Topic 9. Candidates must be able to "read, understand and complete" SQL scripts that query data stored in a single database table, and to identify the output of an SQL statement for given table contents (Cambridge International, 0478 syllabus 2026-2028).

The syllabus limits SQL to these words:

KeywordWhat it does
SELECTChooses which fields (columns) to show
FROMNames the table
WHEREKeeps only records (rows) that meet a condition
ORDER BY ... ASCENDING / DESCENDINGSorts the results
SUMAdds up the values in a numeric field
COUNTCounts records
AND, ORCombine conditions

Nothing else is listed, so you do not need joins, INSERT, UPDATE or LIKE for 0478. Always check the syllabus for your exam year, because Cambridge can update the wording between syllabus cycles. Databases belong to the content examined in Paper 2 (Algorithms, programming and logic).

Tip: The syllabus writes the sort order as ORDER BY ASCENDING and ORDER BY DESCENDING. Copy that style in your answers rather than shortening it, so your query matches what you have been taught.

The practice table

Every example below uses this table, called Laptops. It has six records and five fields. ID is the primary key because every value is unique.

IDBrandTypePriceStock
1ZentaStudent35012
2OrbitGaming9003
3ZentaGaming11005
4LumoStudent4000
5OrbitStudent4508
6LumoGaming9502

The data types are sensible too: ID, Price and Stock are integers, while Brand and Type are text.

A four-step method for reading any SQL query

  1. 1Find FROM. This tells you which table you are using.
  2. 2Apply WHERE. Cross out every record that fails the condition. If there is no WHERE, every record stays.
  3. 3Apply SELECT. Keep only the fields named. * means all fields.
  4. 4Apply ORDER BY, SUM or COUNT. Sort what is left, or total or count it.

Notice that you do not read left to right. The query is written with SELECT first, but the easiest way to work it out is to start with FROM and WHERE. This is the same habit as filling in a trace table: work through it step by step instead of guessing. If you want practice with that skill, see our guide to IGCSE Computer Science trace tables.

Worked examples

Example 1: SELECT with WHERE and ORDER BY

SELECT Brand, Price
FROM Laptops
WHERE Type = 'Gaming'
ORDER BY Price DESCENDING

Step 1: table is Laptops. Step 2: keep only the Gaming records (IDs 2, 3 and 6). Step 3: show only Brand and Price. Step 4: sort by Price, highest first.

BrandPrice
Zenta1100
Lumo950
Orbit900

Example 2: COUNT

SELECT COUNT(ID)
FROM Laptops
WHERE Stock > 0

Keep records where Stock is greater than 0: IDs 1, 2, 3, 5 and 6. ID 4 has no stock. COUNT counts the records that remain, so the output is 5.

Example 3: SUM

SELECT SUM(Stock)
FROM Laptops
WHERE Brand = 'Orbit'

Orbit laptops are IDs 2 and 5, with stock of 3 and 8. SUM adds them: 3 + 8 = 11.

Tip: SUM only makes sense on a numeric field. You can add up Stock or Price, but you cannot sensibly SUM a text field such as Brand. Use COUNT when the question asks "how many".

Example 4: AND

SELECT ID
FROM Laptops
WHERE Type = 'Student' AND Price < 420

AND means both conditions must be true for the same record. Student laptops are IDs 1, 4 and 5. Of those, only IDs 1 (350) and 4 (400) cost less than 420. Output: 1 and 4.

Example 5: OR

SELECT Brand
FROM Laptops
WHERE Brand = 'Lumo' OR Price > 1000

OR means at least one condition must be true. Lumo records are IDs 4 and 6. The only price above 1000 is ID 3 (Zenta, 1100). Records 3, 4 and 6 qualify, so the output, in table order, is Zenta, Lumo, Lumo. Notice that Lumo appears twice, because SQL shows one row per matching record unless told otherwise.

Example 6: Writing a query from a description

Show the brand and stock of every laptop with fewer than 5 in stock, with the lowest stock first.

Break the sentence into parts. Fields: Brand, Stock. Table: Laptops. Condition: Stock < 5. Sort: lowest first, which is ascending.

SELECT Brand, Stock
FROM Laptops
WHERE Stock < 5
ORDER BY Stock ASCENDING

Output: Lumo 0, Lumo 2, Orbit 3.

Common SQL mistakes that cost marks

  • Forgetting FROM. Every query needs a table name.
  • Missing quotes on text. Text values such as 'Gaming' go in quotes. Compare Type = 'Gaming' with the incorrect Type = Gaming.
  • Mixing up COUNT and SUM. COUNT gives how many records; SUM gives a total of a number field. In Example 2, counting gives 5 but summing Stock would give 30.
  • Sorting the wrong way. Ascending is smallest first (or A to Z). Descending is largest first (or Z to A).
  • Including fields that were not selected. If the query says SELECT Brand, your output has only a Brand column, even though the table has five.
  • Losing records when using AND instead of OR. AND is stricter. If your output is empty or smaller than expected, check which word you used.
  • Not checking every record. Cross off records one by one, as in the examples above, instead of scanning the table by eye.

How to practise SQL for IGCSE Computer Science

Reading queries is a skill that improves with repetition, and the research on learning backs this up: actively retrieving and applying what you know produces better long-term memory than re-reading notes (Roediger & Karpicke, 2006). Try this routine:

  1. 1Invent a small table of your own with six or seven records, such as your class, your music collection or a school canteen menu.
  2. 2Write five queries using different keywords, then work out each output on paper.
  3. 3Swap with a friend and check each other's answers.
  4. 4Practise turning a sentence into a query, as in Example 6, because "complete the script" tasks reward this skill.
  5. 5Mix SQL into your wider revision. Our guide to IGCSE command words helps with the wording of other Paper 2 questions, and logic gates and truth tables is another topic where a systematic method wins marks.

Explaining a query out loud is useful too. Describing in your own words what WHERE does and then predicting an output tests whether you really understand, rather than just recognise, the keywords. This is the idea behind learning by teaching, and it is how TeachVerse works: you explain a syllabus topic to an AI pupil, and its answers to exam-style questions show where your explanation had gaps. TeachVerse's questions are original and written in the style of Cambridge IGCSE papers; they are not real past papers.

Quick revision checklist

  • I can name the SQL words the syllabus lists: SELECT, FROM, WHERE, ORDER BY, SUM, COUNT, AND and OR.
  • I can follow FROM, then WHERE, then SELECT, then sort or total.
  • I can say the difference between COUNT and SUM and give an example of each.
  • I can write a query from a sentence, quoting text values correctly.
  • I can explain what a primary key is and choose a suitable one.

Try it yourself

Pick one of the six tables or queries above, cover the answer, and predict the output before checking. Then build your own table and repeat. If you would like to test your database knowledge by teaching it, you can start free on TeachVerse.

Learn it by teaching it.

Free for IGCSE: an AI pupil, topical papers, flashcards and a study plan.

Start free

Keep reading