Which query will display employees whose Salary is greater than the average Salary?
Which query will display employees whose Salary is greater than the average Salary?
Solution
An aggregate function like AVG() cannot be used directly in a WHERE clause, so the average must be computed separately. A subquery does this: the inner query returns a single value, and the outer query compares each employee's Salary with it.
Option 3 is the only one that does this, and it returns all columns of the employees who earn more than the average.
Options 1 and 4: no column name before the ">" operator, and AVG() is used directly in WHERE, so both are syntax errors.
Option 2: HAVING filters groups created by GROUP BY, and it cannot compare a row's Salary with AVG(Salary) without a subquery.
Option 4 also selects only the Salary column, not the employees' full details.
Related questions:
2026: 23 May Shift 1
2025: 16 May Shift 1
2025: 27 May Shift 2
2026: 18 May Shift 2