To count orders of 40 or more per day, this version puts the condition in WHERE:
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(o.order_id) AS big_orders
FROM days AS d
LEFT JOIN orders AS o ON o.ordered_on = d.day
WHERE o.amount >= 40
GROUP BY d.day
ORDER BY d.day;
Now the same condition in ON:
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(o.order_id) AS big_orders
FROM days AS d
LEFT JOIN orders AS o ON o.ordered_on = d.day AND o.amount >= 40
GROUP BY d.day
ORDER BY d.day;
The rows each version groups, side by side:
The WHERE runs after the join. The NULL rows fail o.amount >= 40, and the LEFT JOIN ends up acting like an inner join. In ON, the condition only decides which orders attach, so the day itself stays.
In the editor, finish BIG_REVENUE_BY_DAY: each day's revenue from orders of 40 or more, with the empty days kept.