Monthly Cohort Retention for New ExtraCare Loyalty Members
Last updated: November 29, 2026
Quick Overview
Using extracare_members (member_id, enrolled_at) and store_transactions (member_id, txn_ts, amount), build a cohort table showing, for each enrollment month, the share of members who made a purchase in each of months 0 through 6 after enrolling.
CVS Health
November 29, 20260
0
0 solved
Using extracare_members (member_id, enrolled_at) and store_transactions (member_id, txn_ts, amount), build a cohort table showing, for each enrollment month, the share of members who made a purchase in each of months 0 through 6 after enrolling.
CVS ExtraCare is one of the largest retail loyalty programs in the US, and retail analytics teams track whether new members keep shopping after the signup offer. This tests cohort construction with month offsets and the correct denominator.
What the Interviewer Expects
- Assigns each member to a cohort by enrollment month
- Computes month offset between purchase month and cohort month
- Counts distinct active members per cohort and offset
- Divides by full cohort size, not by active members
- Mentions right censoring for recent cohorts
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 show revenue retention instead of member retention?
- Recent cohorts have fewer observable months. How do you present them?
- How would you split cohorts by acquisition channel (in store vs app)?
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
- Cohort = calendar month of
enrolled_at. - Active in offset k = at least one transaction with positive amount in the k-th calendar month after the cohort month (month 0 is the enrollment month).
- ...
Approach
- Build a cohort CTE with each member's cohort month and cohort size.
- Join transactions, compute
month_offsetfrom year and month differences. - Count distinct members per cohort and offset in ...