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

Examine the description of the EMPLOYEES table:

Which two queries return all rows for employees whose salary is greater than the average salary in their department? (Choose two.)

A.

B.

C.

D.

E.

    Correct Answer:

    To return all rows for employees whose salary is greater than the average salary in their department, we need to compare each employee's salary to the average salary of their respective department. The correct query options here would be using subqueries or analytic functions to achieve this. The correct answers are B and E. B uses a correlated subquery, which calculates the average salary for each department and compares it with the current employee's salary. E uses a window function to calculate the average salary for each department and then filters results based on the comparison. Both methods are valid and correctly solve the problem. Therefore, the correct answers are B and E.

Discussion
Poke90

IN E, the column alias avg_salary from the sub query is used in the WHERE clause of the main query. Is that allowed?

Eltelwany

Yes, it is allowed. It follows from the order of the execution. Since the engine would execute the subquery first, it already knows what the alias refers to.

ArslanAltaf

B & D is correct only. E is not

ArslanAltaf

Correction - B, D and E all worked. All tested

ogi33

D execute but gives no corect data