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.
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.
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.
IN E, the column alias avg_salary from the sub query is used in the WHERE clause of the main query. Is that allowed?
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.
B & D is correct only. E is not
Correction - B, D and E all worked. All tested
D execute but gives no corect data