Worked solution from the Databases Paper 2 Algorithms, Programming and Logic booklet, Part 2 of 2.
Write: ContractNumber [1]
| Field | Data type |
|---|---|
| ContractNumber | text / alphanumeric |
| Months | integer |
| EndDate | date/time |
| Sport | Boolean |
ContractNumber and Months correct [1]
EndDate and Sport correct [1]
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]
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]
▶ 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.