Find all rows where the value is greater than the average value.

Given a table of data with two columns, "id" and "value", this SQL query will find all rows where the value is greater than the average value.

Problem

Given a table of data with two columns, "id" and "value", write a SQL query to find all rows where the value is greater than the average value.
Example input:
id | value
1  | 5
2  | 6
3  | 7
4  | 8
5  | 9
Example output:
id | value
3  | 7
4  | 8
5  | 9

Solution

This solution is in SQL. Our A.I. can create solutions in multiple languages.
by sarastevens
SELECT id, value
FROM table
WHERE value > (SELECT AVG(value) FROM table)

/*

The above solution is optimal because it only requires one pass through the table.

*/

A.I. Evaluation of the Solution

The candidate's solution is correct and demonstrates a good understanding of SQL. The solution is also efficient, as it only requires one pass through the table.

Evaluated at: 2022-11-28 00:16:04