SQL Coding Practice
Practice typing real code syntax, including brackets, punctuation, and indentation. Snippets are for typing practice only and are never executed.
Common table expression
Type the code exactly. Tab inserts four spaces. Code is not executed.
Progress: 0%
Current mismatches: 0
WITH recent_orders AS (
SELECT customer_id, total
FROM orders
WHERE created_at >= '2026-01-01'
)
SELECT
customer_id,
SUM(total) AS total_spent
FROM recent_orders
GROUP BY customer_id
ORDER BY total_spent DESC;
Type the code exactly, including spaces and indentation.