問題文
A developer writes WHERE salary > AVG(salary) in a query over one table and receives a group function is not allowed here error. Which rewrite expresses the same intent correctly?
選択肢
- Put the average in a subquery so that the comparison reads a single value that the inner query works out once for the whole statement.
- Put the average in the HAVING clause so that the comparison reads a single value that the same query computes for the whole table.
- Put the average in the ORDER BY clause so that the comparison reads the sorted position of each row rather than the value of the average.
- Put the average in the select list with an alias so that the comparison reads that alias in the same query as a single value.