0984

Database Concepts

Databases · 5 question types

Exam Frequency Analysis

Past paper frequency (2018 to 2024)

This topic accounts for approximately 4% of your exam marks.

stable
Rare
Stable4%

SQL SELECT queries and database structure (tables, fields, records) appear as 4 to 6 mark questions.

Two functions calculate a single value from a whole column of results rather than listing the rows.

SUM

SUM(field) adds up all the values in a numeric field across the records the query selects.

SELECT SUM(DailyFeedKg)
FROM tbl_zoo
WHERE InCaptivity = 'Yes';

This adds the daily feed for every captive species (35 + 3 + 2 + 1 + 25 + 2 + 20 + 4 = 92), so the query returns a single value: 92.

COUNT

COUNT(field) returns how many records the query selects, rather than the records themselves.

SELECT COUNT(Species)
FROM tbl_zoo
WHERE InCaptivity = 'No';

Two species are not in captivity (Anaconda and Tarantula), so this returns 2. Using COUNT(*) counts every selected record in the same way.

Exam tip

Choosing between SUM, COUNT and ORDER BY

What comes up: a query asks for a total, a number of records, or a sorted list from a single table (often worth 2-3 marks, one per correct clause).

Write: use SUM(field) when the question asks for a total of a numeric column; use COUNT(field) (or COUNT(*)) when it asks how many records match; add ORDER BY field ASC or ORDER BY field DESC when it asks for the results in order.

Watch out: SUM adds the values, while COUNT only counts how many rows there are — using COUNT where the question wants a total (or the other way round) loses the mark. State ASC or DESC explicitly so the sort direction is unambiguous.