🎙 Free live masterclass · Sun, 29 Nov, 7:00 pm IST · Java Full Stack roadmap Register free →
Skills101
← 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?

  1. A.COUNT(*) is not allowed with GROUP BY
  2. B.name is neither grouped nor aggregated, so there's no single value per group
  3. C.dept_id must appear in SELECT
  4. 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 →