📞 0339-0387701 (WhatsApp) Contact

« Back to Database & Data Handling (NCCIA)

Which statement uses a subquery to find employees earning above the average salary?

A. SELECT * FROM Employees HAVING Salary > AVG(Salary)
B. SELECT * FROM Employees WHERE Salary > AVG Salary
C. SELECT * FROM Employees WHERE Salary > (SELECT AVG(Salary) FROM Employees) ✅
D. SELECT * FROM Employees WHERE Salary > AVG(Salary)

Correct Answer: C. SELECT * FROM Employees WHERE Salary > (SELECT AVG(Salary) FROM Employees)

Explanation

An aggregate cannot be used directly in WHERE, so a subquery computes the average first and the outer query compares each salary with it.