Multiple choice technology databases

The following statement will raise an exception on which line?

  1. select dept_name, avg(all salary), count(*) “number of employees”

  2. where deptno = dept_no

  3. and count(*) > 5

  4. group by dept_name

Reveal answer Fill a bubble to check yourself
C Correct answer
Explanation

Aggregate functions like COUNT(*) cannot be used in a WHERE clause - they require HAVING after GROUP BY. The WHERE clause filters rows before grouping, while HAVING filters after grouping.