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 | |
|---|---|---|
| 1HAVING COUNT(*) > 2 | AKeeps only the groups that contain more than two rows | |
| 2GROUP BY house HAVING SUM(points) >= 200 | BKeeps only the houses whose total points are at least 200 | |
| 3WHERE filters individual rows before they are grouped, so it cannot use an aggregate like COUNT(*) | CHAVING is in the wrong place. It must come after GROUP BY, not before it. | |
| 4The correct clause order is WHERE, then GROUP BY, then HAVING | DWHERE runs before grouping, so it cannot use an aggregate function like COUNT(*). Use HAVING COUNT(*) > 2 after GROUP BY instead. | |
| 5SELECT house, COUNT(*) FROM students WHERE COUNT(*) > 2 GROUP BY house; | ESELECT house, COUNT(*) FROM students WHERE yearLevel = 7 GROUP BY house; | |
| 6SELECT house, COUNT(*) FROM students HAVING COUNT(*) > 2 GROUP BY house; | FSELECT house, COUNT(*) FROM students WHERE points > 50 GROUP BY house HAVING COUNT(*) > 2; |
Complete each line of code by filling in the missing parts.
Shade in the letter of the line that contains an error.
HAVING — Filters groups after GROUP BY using an aggregate condition, e.g. HAVING COUNT(*) > 2. WHERE filters rows before grouping. Order: WHERE, GROUP BY, HAVING.SELECT house, COUNT(*) FROM students
GROUP BY house
HAVING COUNT(*) > 2;SELECT category, COUNT(*) FROM products
WHERE price > 2
GROUP BY category;SELECT subjectId, AVG(mark) FROM results
GROUP BY subjectId
HAVING AVG(mark) > 70;SELECT studentId, COUNT(*) FROM orders
GROUP BY studentId
HAVING COUNT(*) > 1;SELECT house, SUM(points) FROM students
GROUP BY house
HAVING SUM(points) > 200;