Write SQL to list the names of students in Year 12, sorted alphabetically.
- SELECT Name FROM Student
- WHERE Year = 12
- ORDER BY Name ASC
Answer SELECT Name FROM Student WHERE Year = 12 ORDER BY Name ASC
A-level Computer Science revision · Exchanging data
SQL retrieves data with SELECT fields FROM table WHERE condition ORDER BY field. LIKE with % matches patterns. JOIN (or INNER JOIN ... ON) combines tables using matching keys. AND, OR, BETWEEN and IN refine conditions.
Watch out In LIKE patterns, % stands for any number of characters.
Write SQL to list the names of students in Year 12, sorted alphabetically.
Answer SELECT Name FROM Student WHERE Year = 12 ORDER BY Name ASC
Which condition finds surnames beginning with S?
What does ORDER BY Price DESC do?
Write an SQL query that lists the Title of every Book whose Price is between 5 and 10.
Answer SELECT Title FROM Book WHERE Price BETWEEN 5 AND 10
A-level Computer Science Pro, OCR H446
£119 once
Price rises to £199 on 1 January. Save £80 by joining before then.
At least 12 months of access
No VAT is charged.