Compare 30, 60 and 90 Day Revenue per Customer Across Acquisition Cohorts
Last updated: November 29, 2026
Quick Overview
Group new customers by the month of their first order and compute average cumulative revenue per customer at 30, 60 and 90 days after that first order, only for customers whose horizon is fully observed.
Amazon
November 29, 20260
0
0 solved
Group new customers by the month of their first order and compute average cumulative revenue per customer at 30, 60 and 90 days after that first order, only for customers whose horizon is fully observed.
A lifetime value question in the style of Amazon marketing and retail finance analytics, used to compare acquisition months and channels on an equal footing. The interviewer checks per-horizon eligibility, revenue windows anchored on each customer's own first order, and an honest denominator.
What the Interviewer Expects
- Anchor every customer's windows on their own first order timestamp
- Use conditional aggregation for the 30, 60 and 90 day windows
- Apply eligibility per horizon so young cohorts are not penalized
- Include zero-revenue customers beyond the first order in the denominator
- Explain whether day 0 revenue is included
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 split this by acquisition channel such as paid search or Prime Day?
- How would you add contribution margin instead of revenue?
- How would you project 365-day value for cohorts that are too young?
- Why might the average be misleading and what would you show alongside it?
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
Table orders(order_id, customer_id, order_ts, order_total, status). Use shipped orders. Revenue at horizon H is the sum of all orders with order_ts < first_order_ts + H days, including the first o...
Approach
firsts: first order time and cohort month per customer, usingMINas a window so I can keep every order row with its anchor.- Per customer, conditional sums give cumulative revenue at each ho...