The Airbnb screen question asks for a user-day panel over an inclusive date range (1 source): one row per user per day, whether or not the user did anything. It's the calendar move in two dimensions.
Predict
Five users over March 9 and 10, both ends included. How many rows does the panel have?
Add a users table with ids 1 to 5 (CREATE TABLE users (user_id INTEGER)), where user 5 has never ordered. CROSS JOIN pairs every row of one table with every row of the other, so users CROSS JOIN days is every user on every day. Then LEFT JOIN the orders:
WITH RECURSIVE days(day) AS ( SELECT '2026-03-09' UNION ALL SELECT date(day, '+1 day') FROM days WHERE day < '2026-03-10')SELECT u.user_id, d.day, COUNT(o.order_id) AS ordersFROM users AS uCROSS JOIN days AS dLEFT JOIN orders AS o ON o.user_id = u.user_id AND o.ordered_on = d.dayGROUP BY u.user_id, d.dayORDER BY u.user_id, d.day;
The ten rows as a grid of users by days, each cell the user's orders that day:
Orders
2026-03-09
2026-03-10
user 1
0
0
user 2
1
0
user 3
0
0
user 4
0
1
user 5
0
0
Five users times two days, both ends included, is ten rows. Users 1, 3 and 5 placed nothing on these days and still get rows of zeros.
Join users to orders with a plain JOIN instead, filtered to these two days, and only users 2 and 4 come back. Then any per-user average over the result quietly skips everyone who didn't order.
Once the panel is dense, windows over it are safe. Each user has exactly one row per day, so a ROWS frame partitioned by user counts days.
In the editor, write USER_DAY_PANEL: the same panel over March 2 and 3, with each user's spend as well as their orders.
Pick an answer above to see the rest
Instructions
1
Write USER_DAY_PANEL: every user in users on every day from March 2 to March 3, with user_id, day, orders, spend, and 0 where they didn't order. Order by user_id, then day.
2
Cross join the users with the days, then LEFT JOIN the orders with both conditions in ON.