Skip to main content
SQL Bug Hunt Medium +20 XP

Aggregate Without GROUP BY

This query fails when mixing aggregate and non-aggregate columns.

SQLFind the bug
1SELECT name, COUNT(*)
2FROM employees;
The bug is on line 1

Select the correct fix

Show answer and explanation

Answer: Add GROUP BY name

When using aggregate functions, all non-aggregated columns in SELECT must appear in GROUP BY.

Hint: Non-aggregated columns need GROUP BY.

What this challenge tests

Bug Hunt in SQL: group-by, aggregate.

Related challenges