DashPass Late Renewals
0:00:00
Let’s say we work on DashPass at DoorDash, and the team suspects that customers who get late deliveries are less likely to renew their monthly subscription. Write a query that compares the renewal rate of monthly units in which the user had at least one late delivery against monthly units with none.
- In
subscription_units, each row is one month of a subscription, andsubscription_typeis'free_trial','monthly'or'annual'. - A renewal’s
last_subscription_unit_idpoints to the unit it renewed (NULL for a first month).
Rules
- A late delivery is a completed, non-pickup order placed during the unit (at or after its start, before its end) with delivered_at later than estimated_delivered_at.
- A unit is renewed if another unit lists it as last_subscription_unit_id.
- Only include units that ended before 2026-11-01.
- is_completed and is_pick_up are never NULL, and a user has at most one monthly unit running at a time.
- Round renewal_rate to 2 decimal places and order by had_late_delivery. A group with no units is simply absent.
Example:
Input:
subscription_units table
| Column | Type |
|---|---|
subscription_unit_id |
INTEGER |
subscription_id |
INTEGER |
user_id |
INTEGER |
subscription_type |
VARCHAR |
subscription_unit_start_date |
DATETIME |
subscription_unit_end_date |
DATETIME |
last_subscription_unit_id |
INTEGER |
orders table
| Column | Type |
|---|---|
order_id |
INTEGER |
user_id |
INTEGER |
is_completed |
BOOLEAN |
is_pick_up |
BOOLEAN |
order_placed_at |
DATETIME |
delivered_at |
DATETIME |
estimated_delivered_at |
DATETIME |
Output:
| Column | Type |
|---|---|
had_late_delivery |
INTEGER |
units |
INTEGER |
renewed_units |
INTEGER |
renewal_rate |
FLOAT |
.
.
.
.
Comments