Fix a December 2026 spend query where users with zero December orders vanish from the LEFT JOIN.
Marketing wants a list of all users and their total spend in December 2026—including users who spent ₹0. Right now, anyone with zero December orders is missing from the output.
3 rows: (1, Aarav), (2, Priya), (3, Rohan)
Aarav: 2 Dec orders (1200, 800) · Priya: 1 Nov order (1500) · Rohan: 0 orders
WHERE o.created_at >= '2026-12-01' filter relative to LEFT JOIN orders o: in SQL query execution order, WHERE runs after the join.WHERE turns a LEFT JOIN into an INNER JOIN because NULL >= '2026-12-01' evaluates to UNKNOWN. Move the date condition into the JOIN ... ON clause (or aggregate conditionally with CASE/FILTER).Ready to run test suite
Edit the code above and press Cmd/Ctrl + Enter or click Run Tests.