Subqueries & CTEs
Exercise · SQL & Querying

Predict, then run it

Predict the output

orders(cust, amt) = (A,10),(A,30),(B,5),(B,15). Orders above their own customer's average — correlated per customer:

SELECT cust, amt FROM orders o WHERE amt > (SELECT AVG(amt) FROM orders o2 WHERE o2.cust = o.cust) ORDER BY cust, amt;

Predict the exact output.