WITH RECURSIVE days(day) AS (
SELECT '2026-03-01'
UNION ALL
SELECT date(day, '+1 day') FROM days WHERE day < '2026-03-04'
)
SELECT d.day,
COUNT(*) AS count_star,
COUNT(o.order_id) AS count_orders
FROM days AS d
LEFT JOIN orders AS o ON o.ordered_on = d.day
GROUP BY d.day
ORDER BY d.day;
Here are the rows each COUNT sees for March 3 and 4:
The LEFT JOIN gives March 4 one row whose order columns are all NULL. COUNT(*) counts that row. COUNT(o.order_id) skips the NULL and gets 0.
SUM trips the other way. Over nothing but NULLs it returns NULL, not 0, so an empty day's SUM(o.amount) needs a COALESCE(..., 0) around it.
In the editor, write SPEND_PER_DAY: orders and spend per day, with the LEFT JOIN on orders itself.