WITH
WITH names a subquery so you can read the query top to bottom.
task
Rewrite a nested query as two steps: first the total of each order (unit_cents * qty summed), then the ids of orders whose total is above 10 times the average order total.
Run a query to see rows here.
Run EXPLAIN on the statement under the cursor: Plan tab, button Explain.
No tables yet.
WITH names a subquery so you can read the query top to bottom.
Rewrite a nested query as two steps: first the total of each order (unit_cents * qty summed), then the ids of orders whose total is above 10 times the average order total.