Learn in your language
Skip to content
IGCSE · Cambridge (CIE) · 0478

Add matching values with SUM

Use SUM to total a numeric field across all records or a filtered subset.

Cambridge IGCSE Computer Science 0478 · Databases · 2026–2028 Version 6 · Topic 9
Exam scope and assessment notes

This sequence follows Cambridge IGCSE Computer Science 0478, 2026–2028 syllabus Version 6, Topic 9. It covers single-table databases only and the specified SELECT, FROM, WHERE, ORDER BY, SUM, COUNT, AND and OR content. The official specimen also demonstrates NOT in a filter. Multi-table joins, GROUP BY, database implementation and the separate 2029–2031 syllabus are not mapped here. Practice is original, self-checked and does not award an official Cambridge grade. Full timed papers and human subject-teacher review remain outstanding.

Before you begin

  • Be able to read a small table and compare values. Each lesson introduces the database and SQL terms it uses.

Work on paper. Try each question before revealing help, and explain why your method works.

Quick readiness check

Which field is more suitable for SUM: Price or ProductCode?

What you will learn

  • Identify a numeric field to total
  • Use SUM in a SELECT statement
  • Combine SUM with a WHERE condition

SUM aggregates numeric values

SUM(FieldName) adds the values in a numeric field. It is suitable for quantities such as NumberInStock or Points, not for a text field such as Title.

The query returns one total for the selected set of records.

Filter the set before calculating the total

A WHERE condition limits which rows contribute to SUM. For example, sum stock only for records where Container = "Can".

Check the units and data type. A sum is meaningful only if the field values represent quantities that can be added.

Pause and explain

A query must total seats for Coding workshops only. Which parts are needed?

Put the idea to work

Worked example

A shop table SOFTDRINKS has NumberInStock and Container. Write a query to total stock for cans.

Show the worked solution
  1. Choose the numeric field NumberInStock.
  2. Apply SUM to the stock field.
  3. Filter Container to Can.

Answer SELECT SUM(NumberInStock) FROM SOFTDRINKS WHERE Container = "Can";

Try a topic test

Choose Easy, Normal or Difficult. Save your answers and open worked review after finishing.

Test this topic →

From guided practice to a new situation

Write your answer and reasoning first. Use a hint only if you are stuck. The model solution is for self-checking; your written work is not automatically marked.

1 · Guided

Stock values for Can records are 12, 8 and 5. What does SUM(NumberInStock) return for those rows?

Give me a hint

Add only the values from matching records.

Compare my reasoning
  1. Add 12 and 8 to get 20.
  2. Add 5 to get 25.
  3. The sum is 25.

25 units.

Look for these in your work

  • Rows included
  • Sum correct
2 · Independent

Write a query to total Points for TEAM records where League = "East".

Give me a hint

Use SUM on the numeric field and a filter on League.

Compare my reasoning
  1. Select SUM(Points).
  2. Use TEAM as the table.
  3. Filter League = "East".

SELECT SUM(Points) FROM TEAM WHERE League = "East";

Look for these in your work

  • Numeric aggregate
  • Correct table
  • Filter
3 · Transfer

A learner writes SUM(ShowNumber) to report total ticket sales. Explain the mismatch and name the field they should total instead.

Give me a hint

ShowNumber identifies a record; find the quantity representing sales.

Compare my reasoning
  1. An identifier is not an amount.
  2. The query should add ticket quantities or revenue.
  3. Use the numeric field matching the requested total, such as TicketsSold.

SUM should use a numeric quantity such as TicketsSold or Revenue, not the show identifier.

Look for these in your work

  • Identifier distinction
  • Relevant quantity

Common mistakes

  • Summing text or identifier fields
  • Forgetting the filter when only some records qualify
  • Adding the number of records instead of their field values
Recall without your notes

What can you explain now?

Which function totals a numeric field?

Compare with the explanation

SUM

SUM adds the values in the named field.

After trying it yourself, choose your next review. This is your self-assessment.

Your review choice appears on Today. Sign in to sync it across devices.

Make it stick

When is SUM more appropriate than COUNT?

If you needed the solution, close it and solve the problem again from a blank page. A correct answer is stronger when you can explain the reason for each step.

Keep learning Computer Science

Course scope and assessment

165 original lessons map the listed objectives across all 10 main topics in the 2026–2028 Version 6 syllabus, with worked explanations and guided, independent and transfer practice. This is mapped teaching coverage, not proof of full exam readiness. Three earlier starter lessons remain available but are not counted as syllabus-mapped teaching. Practical programming experience in an executable browser workspace, full timed-paper practice, human subject-teacher review and the separate 2029–2031 syllabus remain outstanding. Practice is self-checked and does not award an official Cambridge grade.

StudyForA · Learn with understanding

Original teaching content and links to official sources. Check your exam year and qualification before using a resource.