Loading…
You can define multiple CTEs separated by commas:
WITH
cte1 AS (SELECT ...),
cte2 AS (SELECT ... FROM cte1)
SELECT * FROM cte2;
Later CTEs can reference earlier ones!
Create two CTEs:
order_totals - Calculate total per order:customer_totals - Calculate total per customer:Finally, join with customers to show name and total_spent for customers who spent over $200.
Downloading SQL engine… (one-time)
This runs entirely in your browser and is cached for next time.