Track Prime Members Who Downgraded From Annual to Monthly Plans

Last updated: November 29, 2026

Quick Overview

From a Prime plan history table, count members each month who switched from an annual plan directly to a monthly plan, and the median number of days they spent on annual before switching.

Amazon
Data Manipulation (SQL/Python)
Data Scientist
Amazon
November 29, 2026
Data Scientist
Technical Screen
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


From a Prime plan history table, count members each month who switched from an annual plan directly to a monthly plan, and the median number of days they spent on annual before switching.

A subscription analytics question in the style of Amazon Prime membership teams, where plan mix affects revenue predictability. The interviewer checks LAG over an event history, correct definition of a direct transition, and a duration from consecutive rows.

What the Interviewer Expects
  • Order plan events per member and use LAG for the previous plan and its start
  • Define a downgrade as previous plan ANNUAL and current plan MONTHLY
  • Compute time on annual from the previous event to the switch
  • Aggregate by switch month with a median
  • Clarify how cancellations in between are treated
Key Topics to Cover
LAG
state transitions
event history
PERCENTILE_CONT
subscriptions
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
  • Should ANNUAL to CANCELLED to MONTHLY count as a downgrade?
  • How would you compute the upgrade rate in the opposite direction?
  • How would you relate downgrades to a price increase date?
  • How would you normalize the count by annual members at the start of the month?
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

Table prime_plan_events(customer_id, event_ts, plan) with plan in ANNUAL, MONTHLY, STUDENT, CANCELLED. Each row starts a new plan state. A direct downgrade is an ANNUAL state immediately...

Approach
  1. Remove repeat rows of the same plan so renewals do not reset the start: keep a row only if its plan differs from the previous row's plan.
  2. On the cleaned history, LAG(plan) and LAG(event_ts) ...

Submit Your Answer
Markdown supported