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

Q20 · 2210/23/O/N/24 Q11

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

Q202210/23/O/N/24original Q11Structured · 7 marks
Question 11 from 2210/23/O/N/24

Worked solution

(a)

Rows with WeightKg = 75 are MT06 (67.35) and MT12 (62.75). ORDER BY PricePerBag sorts from the lowest price, so MT12 comes first.

MtNoName
MT12Pebbles large
MT06Cobbles

Row MT12 Pebbles large [1]

Row MT06 Cobbles [1]

Rows in the correct order [1]

(b)(i)

SELECT Name
FROM BuildStock
WHERE InStock = "No";

Correct SELECT and FROM clauses [1]

Correct WHERE clause (WHERE NOT InStock, InStock = FALSE or NumberBags = 0 also score) [1]

(ii)

Use the InStock field in the WHERE clause [1]

and check for false / No [1]

Or use the NumberBags field in the WHERE clause and check for 0. Only one of these two routes is needed, so it scores 2 marks.

KEY IDEAORDER BY sorts low to high by default, and out of stock can be found through InStock or NumberBags.
TOTAL 7 marks

Official mark scheme

Mark scheme for 2210/23/O/N/24 question 11
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.