Skip to main contentSkip to solution

Which query will display employees whose Salary is greater than the average Salary?

Solution

✅ Correct Option: 3

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 SELECT AVG(Salary) FROM EMP\text{SELECT AVG(Salary) FROM EMP} 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.

Keyboard Shortcuts

  • Left arrow: Previous question
  • Right arrow: Next question
  • S key: Jump to solution
  • Q key: Jump to question