Compute Monthly Churn Rate From Subscription Start and End Dates

Last updated: November 29, 2026

Quick Overview

Given subscription records with a start date and an optional end date, compute for each month the opening subscriber count, the number who churned during the month, and the churn rate.

Amazon
Data Manipulation (SQL/Python)
Data Scientist
Amazon
November 29, 2026
Data Scientist
Take-home Project
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given subscription records with a start date and an optional end date, compute for each month the opening subscriber count, the number who churned during the month, and the churn rate.

A Python data manipulation take-home in the style of Amazon subscription businesses such as Audible and Amazon Music Unlimited. The interviewer checks a precise definition of the opening base, clean month arithmetic across year boundaries, and correct treatment of subscriptions that start and end inside the same month.

What the Interviewer Expects
  • Define opening subscribers as active on the first day of the month
  • Count churn only among the opening base
  • Handle open-ended subscriptions with no end date
  • Iterate months correctly across December to January
  • Return None rather than dividing by zero for empty months
Key Topics to Cover
churn rate
date arithmetic
subscriptions
Python
denominators
How to Approach This
  1. Clarify the schema and expected output format before writing queries.
  2. Use CTEs (WITH clauses) to break complex queries into readable steps.
  3. Consider window functions (ROW_NUMBER, RANK, LAG, LEAD) for ranking and sequential analysis.
  4. Watch for NULLs, duplicates, and edge cases in JOINs and GROUP BY.
  5. For pandas, prefer vectorized operations over row-by-row iteration.
Possible Follow-up Questions
  • How would you count subscribers who join and churn within the same month?
  • How would you vectorize this with pandas for millions of subscriptions?
  • How would you separate voluntary cancellations from payment failures?
  • How would you convert monthly churn into expected subscriber lifetime?
Sharpen Your Skills on Codemia

Practice similar problems with our interactive workspace, get AI feedback, and track your progress.

Practice SQL Problems
Sample Answer
Clarify the Data

Input: a list of (sub_id, start_date, end_date) where end_date is the last paid day or None if still active. Definitions:

  • Opening base for month M: subscriptions that started before the first ...
Approach

Loop month by month from the first to the last month. For each month compute the first day of the next month with a small helper that rolls the year over. Filter the opening base, count churners insid...


Submit Your Answer
Markdown supported