Use the tables below.
| TutorID | TutorName |
|---|---|
| 1 | Mr Khan |
| 2 | Ms Reid |
| 3 | Mr Cole |
| StudentID | Name | Year | TutorID |
|---|---|---|---|
| 1 | Aisha | 12 | 1 |
| 2 | Ben | 13 | 2 |
| 3 | Chloe | 12 | 1 |
| 4 | Dev | 13 | 3 |
| 5 | Elin | 12 | 2 |
| 6 | Femi | 12 | 1 |
| StudentID | Subject | Score |
|---|---|---|
| 1 | CS | 78 |
| 1 | Maths | 65 |
| 2 | CS | 55 |
| 2 | Maths | 70 |
| 3 | CS | 90 |
| 3 | Maths | 82 |
| 4 | CS | 48 |
| 5 | CS | 66 |
| 5 | Maths | 71 |
| 6 | CS | 72 |
Write an SQL query to list the names of all Year 12 students in reverse alphabetical order. [3]
- SELECT Name FROM Student (allow Student.Name; do not accept SELECT * as the question asks for names only)(1)
- WHERE Year = 12 (allow Year = '12')(1)
- ORDER BY Name DESC (reject ORDER BY Name or ORDER BY Name ASC, which sort A to Z)(1)
- Answer: SELECT Name FROM Student WHERE Year = 12 ORDER BY Name DESC; output Femi, Elin, Chloe, Aisha
- Examiner tip: DESC is needed for reverse order; ORDER BY on its own sorts ascending (A to Z).