A gym stores data in a relational database with two tables, Members and Bookings.
Members
| MemberID | FirstName | Surname | Town | JoinYear |
|---|---|---|---|---|
| 101 | Amira | Khan | Leeds | 2021 |
| 102 | Ben | Clarke | York | 2023 |
| 103 | Chloe | Evans | Leeds | 2022 |
| 104 | Daniel | Okafor | Hull | 2020 |
| 105 | Ella | Morgan | Bradford | 2024 |
| 106 | Femi | Adeyemi | Leeds | 2023 |
Bookings
| BookingID | MemberID | ClassName | Day |
|---|---|---|---|
| B01 | 101 | Yoga | Mon |
| B02 | 103 | Spin | Tue |
| B03 | 102 | Yoga | Wed |
| B04 | 106 | Pilates | Mon |
| B05 | 103 | Yoga | Thu |
| B06 | 105 | Spin | Fri |
Write an SQL query to display the first name and surname of every member who lives in Leeds, in alphabetical order of surname. [3]
- SELECT FirstName, Surname (either order; allow Members.FirstName etc.; reject SELECT *)(1)
- FROM Members WHERE Town = 'Leeds' (allow double quotes; ignore case of keywords)(1)
- ORDER BY Surname (allow ASC included or omitted; reject DESC)(1)
- Answer:
SELECT FirstName, Surname FROM Members WHERE Town = 'Leeds' ORDER BY Surname ASC– returns Femi Adeyemi, Chloe Evans, Amira Khan - Examiner tip: Text values in a WHERE clause need quotation marks: Town = 'Leeds'.