Days from signup to first order

dates

Days from signup to first order

Stripe SQL Interview Question

Stripe's growth team tracks how long an online store's new customers take to make their first purchase after signing up.

For each customer who has placed at least one order, find their name and the number of days from signing up to their first order, as days_to_first_order. Count an order of any status as a first order.

Asked of

  • Data Analyst
  • Product Analyst
  • Data Scientist
  • Analytics Engineer

customersTable10 rows

Column NameType
customer_idBIGINT
nameVARCHAR
countryVARCHAR
segmentVARCHAR
signup_dateDATE

ordersTable35 rows

Column NameType
order_idBIGINT
customer_idBIGINT
order_dateDATE
statusVARCHAR
amountDOUBLE

customersExample Input

customer_idnamecountrysegmentsignup_date
1Priya SharmaIndiaconsumer2023-01-14
2Marcus WebbUnited Statesenterprise2023-02-03
3Ana SousaBrazilconsumer2023-02-27
4Liam O'ConnorIrelandsmall_business2023-03-15
5Yuki TanakaJapanenterprise2023-04-02
6Fatima Al-RashidUnited Arab Emiratesconsumer2023-05-21
7Daniel OkaforNigeriasmall_business2023-06-08

ordersExample Input

order_idcustomer_idorder_datestatusamount
100112024-01-05completed120.5
100222024-01-07completed2400
100312024-01-11completed89.99
100432024-01-15canceled45
100542024-01-18completed610.75
100622024-01-22completed1850.25
100752024-01-29completed3200
100812024-02-02refunded75
100962024-02-06completed55.4
101032024-02-09completed132.6

Example Output

namedays_to_first_order
Ana Sousa322
Fatima Al-Rashid261
Liam O'Connor309
Marcus Webb338
Priya Sharma356
Yuki Tanaka302

Explanation

Priya Sharma signed up on January 14, 2023, and placed a first order on January 5, 2024, which is 356 days later. Daniel Okafor has never ordered, so that name does not appear.

The example above is a small slice of the data. Your query runs against the full tables.