1z0-071 Exam QuestionsBrowse all questions from this exam

1z0-071 Exam - Question 180


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

Show Answer
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

7 comments
Sign in to comment
MooonLightOption: A
Apr 24, 2023

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

Rik92
May 3, 2023

You are correct. In that case you would use HAVING

zouveOption: A
Jul 2, 2023

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

musafirOption: B
Jun 25, 2023

B is correct But I think C as well is correct

jm9999Option: A
Oct 4, 2023

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

c818820Option: B
Jan 7, 2024

B is the Answer.

yaya32Option: A
Jan 22, 2024

For me A is correct.

ArslanAltafOption: A
May 4, 2024

--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.