Thirty Day Repeat Purchase Rate by Acquisition Channel
Last updated: November 29, 2026
Quick Overview
Given users (with signup channel) and orders (with status), compute for each acquisition channel the share of first-time buyers who place a second completed order within 30 days of their first completed order.
Temu
November 29, 20260
0
0 solved
Given users (with signup channel) and orders (with status), compute for each acquisition channel the share of first-time buyers who place a second completed order within 30 days of their first completed order.
Temu spends heavily on paid channels, so whether those buyers come back without another ad is a key question for growth teams. A screening SQL question like this checks window functions, correct handling of cancelled or refunded orders, and a careful date boundary.
What the Interviewer Expects
- Define first order using completed orders only
- Use ROW_NUMBER rather than MIN to get an ordered sequence
- Apply the 30 day window from the first order, not from signup
- Use buyers, not all signups, as the denominator
- Guard against division by zero
Key Topics to Cover
How to Approach This
- Clarify the schema and expected output format before writing queries.
- Use CTEs (WITH clauses) to break complex queries into readable steps.
- Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
- Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
- For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
- How would you exclude users whose 30 day window has not finished yet?
- How would you compare channels fairly when their signup mix by country differs?
- How would you count a second order placed on the same day as the first?
- What would make this number misleading as a measure of channel quality?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice SQL ProblemsSample Answer
Clarify the Data
users(user_id, signup_date, channel) and orders(order_id, user_id, order_date, status) with status in completed, cancelled, refunded. Only completed orders count. A repeat is any completed order a...
Approach
Number each user's completed orders by date (order_id breaks ties). Row 1 is the first order. A user is a repeater if some row with rn > 1 falls within 30 days of row 1. Join back to users for the c...