Customers Who Came Back Within 30 Days

medium
Unit 11 · Window Functions IV0/3 to milestone

A customer who places a second order within 30 days of their first is far more likely to stick around. Find them.

Return name, first_order, second_order (dates) and days_between (a whole number of days) for every customer whose second order was within 30 days (inclusive) of their first. Sort by days_between, then name.

Schema

customers(id, name, country, signup_date)
orders(id, customer_id, order_date, total)
#window-functions#retention#self-join1 visible + 1 hidden tests
query.sql · SQLite
Loading editor…
Run your code to see results. ⌘↵ to run · ⌘⇧↵ to submit
Customers Who Came Back Within 30 Days · TechGradify