SQL Bug Hunt Medium +20 XP
GROUP BY Error
This query fails. What's wrong?
SQLFind the bug
1
SELECT department, name, COUNT(*)2
FROM employees3
GROUP BY department; The bug is on line 1
Select the correct fix
Show answer and explanation
Answer: Remove name or add it to GROUP BY
Every non-aggregate column in SELECT must appear in GROUP BY. 'name' is not aggregated or grouped.
Hint: All non-aggregate columns must be in GROUP BY.
What this challenge tests
Bug Hunt in SQL: group-by, aggregation.