Compare Repeat Purchase Rates by Customers' First Purchased Category
Last updated: November 29, 2026
Quick Overview
Group new customers by the product category of their first order and compute the share who placed a second order within 60 days, for each first category and acquisition quarter.
Amazon
November 29, 20260
0
0 solved
Group new customers by the product category of their first order and compute the share who placed a second order within 60 days, for each first category and acquisition quarter.
A cohort question in the style of Amazon retail growth analytics, used to decide which entry categories (for example Grocery versus Electronics) to promote to new customers. The interviewer checks first-order attribution, handling of multi-category first orders, and an observable 60-day window.
What the Interviewer Expects
- Identify each customer's first order with ROW_NUMBER
- Pick one category for a multi-item first order with a stated rule
- Look for a later distinct order within 60 days
- Exclude customers whose 60-day window is not complete
- Report cohort sizes along with rates
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 control for price point when comparing categories?
- How would you attribute the first order to several categories with fractional weights?
- What does this analysis not tell you about causality?
- How would you extend it to the category of the second order?
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
Tables: orders(order_id, customer_id, order_ts, status) and order_items(order_id, asin, item_total) with products(asin, category). A first order can contain several categories; I attribute it to...
Approach
- Number each customer's shipped orders; the first is
rn = 1. - For first orders, rank categories by spend and take the top one.
- Join a later order of the same customer within `(first_ts, first...