▸_sqlgym

53. Orders Above the Overall Average

EasySubqueriescomparison to scalar subqueryAVGsubquery in WHERE

Comparing a column to a single value returned by a subquery is one of the most common subquery patterns. The subquery runs once and produces a scalar threshold.

Task: return the orders whose amount is strictly greater than the average amount across all orders.

Return columns order_id, amount. Order by amount descending, then order_id ascending.

Tables
Loading schema…
Expected outputrows must come back in this order
Computing expected output…

This is the result for the example data above. On Submit your query is graded against this example plus 4 hidden edge cases 5test cases in all. A sloppy query that only fits the example won't pass.

SQL
⌘/Ctrl+↵ run · ⇧⌘/Ctrl+↵ submit
Run a query to see its output here.