🎴 Flashcard Mode
Oracle PL/SQL Programming Quiz
Card1 / 20
Mastered0
Review0
QuestionClick to flip
The following statement will raise an exception on which line? select dept_name, avg(all salary) ,count() “number of employees” from emp , dept where deptno = dept_no and count() > 5 group by dept_name order by 2 desc;
AnswerClick to flip back
A
and count(*) > 5
💡 Explanation:
Aggregate functions like COUNT() cannot be used in the WHERE clause - they must appear in HAVING after GROUP BY. The line 'and count() > 5' is in the WHERE clause, which causes an error. To filter groups based on aggregate values, use HAVING after GROUP BY. The correct query should move that condition to a HAVING clause. The alias in quotes and the AVG(ALL salary) syntax are valid.