Tip: Choose Save as PDF in the print dialog to download. Use A4 paper size.
Shade in the A or B circle for each question.
Draw a line connecting each item on the left to its match on the right.
| Left column | Right column | |
|---|---|---|
| 1SELECT students.firstName, results.mark FROM students JOIN results ON students.studentId = results.studentId WHERE results.mark > 80 | AJoins students to results, then sorts the joined rows by mark from highest to lowest | |
| 2SELECT students.firstName, results.mark FROM students JOIN results ON students.studentId = results.studentId ORDER BY results.mark DESC | BJoins students to results, then keeps only the joined rows where the mark (a field from the second table) is above 80 | |
| 3The correct clause order for a join query is SELECT, FROM, JOIN ... ON, WHERE, ORDER BY | CORDER BY is placed before WHERE. WHERE must come first, then ORDER BY at the end. | |
| 4A join can be filtered using a field from the second table, so only matching joined rows are kept | DSELECT products.name, orders.quantity FROM orders JOIN products ON orders.productId = products.productId WHERE products.category = 'Stationery' | |
| 5SELECT students.firstName, results.mark FROM students JOIN results ON students.studentId = results.studentId ORDER BY results.mark WHERE results.mark > 50 | ESELECT students.firstName, subjects.name FROM results JOIN subjects ON results.subjectId = subjects.subjectId WHERE subjects.name = 'Maths' ORDER BY students.firstName | |
| 6SELECT students.firstName, results.mark FROM students JOIN results WHERE results.mark > 80 ON students.studentId = results.studentId | FWHERE is placed before the ON condition. ON must directly follow JOIN, and WHERE must come after it. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
JOIN ... ON ... WHERE ... ORDER BY — After JOIN ... ON links two tables, WHERE filters the joined rows and ORDER BY sorts them. Clause order: SELECT, FROM, JOIN ON, WHERE, ORDER BY.SELECT name, price FROM orders JOIN products
ON orders.productId = products.productId
WHERE category = 'Tech' ORDER BY priceSELECT name, mark FROM results JOIN subjects
ON results.subjectId = subjects.subjectId
WHERE name = 'Maths' ORDER BY mark DESCSELECT name, mark FROM results JOIN subjects
ON results.subjectId = subjects.subjectId
WHERE name = 'Maths' ORDER BY mark DESCSELECT name, price FROM orders JOIN products
ON orders.productId = products.productId
WHERE category = 'Tech' ORDER BY priceSELECT name, price FROM orders JOIN products
ON orders.productId = products.productId
WHERE category = 'Tech' ORDER BY price