← Quiz: GROUP BY and HAVING: all 10 questions
Quiz: GROUP BY and HAVING · Question 5 of 10
Why is SELECT name, COUNT() FROM employees GROUP BY deptid invalid in standard SQL?
Why is SELECT name, COUNT(*) FROM employees GROUP BY dept_id invalid in standard SQL?
- A.COUNT(*) is not allowed with GROUP BY
- B.name is neither grouped nor aggregated, so there's no single value per group
- C.dept_id must appear in SELECT
- D.GROUP BY needs ORDER BY
Answer & explanation
Correct answer: name is neither grouped nor aggregated, so there's no single value per group
Each output row is a group; a non-grouped column could have many values in it.
Can you get the rest right without peeking?
Take the timed Quiz: GROUP BY and HAVING quiz free. Pass it to earn XP and count towards your certificate.
Start the quiz →