Exam 1z0-071 All QuestionsBrowse all questions from this exam
Question 180

Which statement is true about using functions in WHERE and HAVING?

    Correct Answer: A

    Aggregate functions cannot be used directly in the WHERE clause because they operate on groups of rows rather than individual rows. To filter results based on aggregate functions, it is necessary to use a subquery within the WHERE clause to first compute the aggregate values or use the HAVING clause, which is designed to filter groups based on aggregate values. Therefore, using aggregate functions in the WHERE clause does indeed require a subquery.

Discussion
MooonLightOption: A

I thought aggregate functions cannot be used in the WHERE clause?

Rik92

You are correct. In that case you would use HAVING

zouveOption: A

A select EmployeeId, sum(amount) from Sales group by Employee where EmployeeId in ( select max(EmployeeId) from Employees)

ArslanAltafOption: A

--B WRONG --select avg(salary) from emp group by dept_id having avg(salary) > 1000; --C WRONG --select last_name from emp where upper(last_name) like 'A%'; --D WRONG --Having is Used for Agg Functions. Single-row functions do not require grouping.

yaya32Option: A

For me A is correct.

c818820Option: B

B is the Answer.

jm9999Option: A

Example: select employee_id from employees where salary > (select avg(salary) from employees);

musafirOption: B

B is correct But I think C as well is correct