Databases · 5 question types
Past paper frequency (2018 to 2024)
This topic accounts for approximately 4% of your exam marks.
SQL SELECT queries and database structure (tables, fields, records) appear as 4 to 6 mark questions.
ORDER BYsorts the records in the result by a chosen field, either ascending or descending.
ORDER BY is added after the WHERE clause (or after FROM if there is no WHERE). The direction is set with ASC (ascending: A→Z, smallest first) or DESC (descending: Z→A, largest first). If neither is written, the default is ascending.
SELECT Species, DailyFeedKg
FROM tbl_zoo
WHERE InCaptivity = 'Yes'
ORDER BY DailyFeedKg DESC;
This lists the captive species from the largest daily feed to the smallest, so Giraffe (35) appears first, then Bison (25), then Gorilla (20), and so on down to Macaw (1).
You can sort on text too. ORDER BY Species ASC would list the species in alphabetical order.