Days Between a Customer's Orders

medium
Unit 11 · Window Functions IV0/3 to milestone

How often do customers come back? For every order, return customer_id, order_date and days_since_previous: the whole number of days since that customer's previous order, or NULL for their first order.

Sort by customer_id, then order_date.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#window-functions#lag#dates1 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Days Between a Customer's Orders · TechGradify