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 class, AVG(score) FROM results GROUP BY class; | ACounts the students in each year level and lists the biggest group first | |
| 2SELECT year, COUNT(*) FROM students GROUP BY year ORDER BY COUNT(*) DESC; | BGives the average score for each class, with one result row per class | |
| 3Splitting rows into groups that share a value, then adding up a number for each group, such as total sales per shop | CSELECT team, AVG(points) FROM games GROUP BY team ORDER BY AVG(points) DESC; | |
| 4Sorting the grouped results so the group with the highest average comes first | DThe clauses are in the wrong order. GROUP BY must come before ORDER BY. | |
| 5SELECT class, AVG(score) FROM results; | EGROUP BY class is missing, so AVG(score) is not worked out for each class. Add GROUP BY class before the semicolon. | |
| 6SELECT class, COUNT(*) FROM students ORDER BY class GROUP BY class; | FSELECT shop, SUM(sales) FROM orders GROUP BY shop; |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
GROUP BY — An SQL clause that sorts rows into groups sharing the same field value, then applies an aggregate like AVG or COUNT to each group, giving one result row per group (e.g. average score per class).SELECT class, AVG(score)
FROM results
GROUP BY class;SELECT year, COUNT(*)
FROM students
GROUP BY year;SELECT team, SUM(points)
FROM games
GROUP BY team;SELECT class, AVG(score)
FROM results
GROUP BY class ORDER BY AVG(score) DESC;SELECT pet, COUNT(*)
FROM survey GROUP BY pet
ORDER BY COUNT(*) DESC;