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 firstName FROM students WHERE points > (SELECT AVG(points) FROM students); | ASELECT * FROM students WHERE yearLevel = (SELECT MAX(yearLevel) FROM students); | |
| 2SELECT name FROM products WHERE productId IN (SELECT productId FROM orders); | BSELECT firstName FROM students WHERE studentId IN (SELECT studentId FROM results WHERE mark > 90); | |
| 3A sub-selection is a SELECT written inside brackets within another statement | CThe inner query returns two columns, but IN needs a subquery that returns only one column to compare with productId | |
| 4A subquery can return a list of values, so the outer WHERE can test membership using IN | DLists the products that appear in at least one order | |
| 5SELECT firstName FROM students WHERE points > SELECT AVG(points) FROM students; | EThe inner SELECT is not wrapped in brackets, so the sub-selection is not valid | |
| 6SELECT name FROM products WHERE productId IN (SELECT productId, quantity FROM orders); | FLists students whose points are above the average points of all students |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WHERE points > (SELECT AVG(points) FROM students) — A sub-selection is a SELECT inside brackets within another statement. The inner query runs first and its result is used by the outer query, such as in a WHERE condition.SELECT firstName FROM students
WHERE points > (SELECT AVG(points)
FROM students);SELECT firstName, points FROM students
WHERE points > (SELECT AVG(points)
FROM students);SELECT name FROM subjects
WHERE subjectId IN (SELECT subjectId
FROM results WHERE mark > 85);SELECT firstName FROM students
WHERE studentId IN (SELECT studentId
FROM orders);SELECT name FROM products
WHERE price > (SELECT AVG(price)
FROM products);