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 | |
|---|---|---|
| 1WHERE mark > (SELECT AVG(mark) FROM results) | ASELECT firstName FROM students WHERE points = (SELECT MIN(points) FROM students); | |
| 2WHERE price = (SELECT MAX(price) FROM products) | BKeeps only rows whose mark is above the average mark of all results | |
| 3Find students whose points are below the lowest-scoring value in a comparison, using MIN in a sub-query to return one value | CThe sub-query returns every mark, not one value, so the outer WHERE cannot compare a single mark to it. | |
| 4Compare each row to the average by putting an aggregate sub-query in brackets after the comparison operator | DSELECT studentId FROM results WHERE mark > (SELECT AVG(mark) FROM results); | |
| 5SELECT * FROM results WHERE mark > SELECT AVG(mark) FROM results; | EKeeps only the product or products with the highest price | |
| 6SELECT * FROM results WHERE mark > (SELECT mark FROM results); | FThe sub-query is not wrapped in brackets, so SQL cannot tell where the inner query starts and ends. |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
WHERE mark > (SELECT AVG(mark) FROM results) — A sub-query in brackets returns one value, like the average. The outer WHERE compares each row's field to it. MIN or MAX work too.SELECT studentId, mark FROM results
WHERE mark > (SELECT AVG(mark)
FROM results);SELECT studentId, mark FROM results
WHERE mark > (SELECT AVG(mark)
FROM results);SELECT name, price FROM products
WHERE price = (SELECT MAX(price)
FROM products);SELECT firstName, points FROM students
WHERE points = (SELECT MIN(points)
FROM students);SELECT name, price FROM products
WHERE price < (SELECT AVG(price)
FROM products);