Cambridge O Level Computer Science 2210 · 9.4 Structured query language (SQL)

Q18 · 2210/22/M/J/24 Q10

Worked solution from the Databases Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 2.

Q182210/22/M/J/24original Q10Structured · 8 marks
Question 10 from 2210/22/M/J/24

Worked solution

(a)

Write: ContractNumber [1]

(b)

FieldData type
ContractNumbertext / alphanumeric
Monthsinteger
EndDatedate/time
SportBoolean

ContractNumber and Months correct [1]

EndDate and Sport correct [1]

(c)

Statement 1: SUM adds up the Months values, so it finds the total number of months for all contracts [1]

Statement 2: COUNT counts records, so it finds the number of contracts [1]

Statement 2 only counts the contracts that are subscribed to News (News is true) [1]

(d)

SELECT ContractNumber
FROM Contract
WHERE News AND Sport;

ContractNumber selected [1]

News and Sport both in the WHERE part joined by AND (either order; News = TRUE is also fine) [1]

KEY IDEAA unique text code makes the key, SUM adds, COUNT counts, and AND joins two conditions.
TOTAL 8 marks

Official mark scheme

Mark scheme for 2210/22/M/J/24 question 10
VIDEO
▶ Topic lesson

A lesson on this topic · by Mr Bulmer's Learning Zone. Tap the picture to open it on YouTube.

Solutions follow the official Cambridge mark schemes; marks are shown in grey. Videos are from other YouTube channels. Paper codes read component / series / year: M/J = May/June, O/N = October/November. Past-paper questions © UCLES, reproduced for classroom practice.