Monthly Subscription Renewal Rate by Sub Tier

Last updated: November 29, 2026

Quick Overview

Given `subscriptions(user_id, channel_id, tier, period_month)` with one row per user, channel and paid month, write SQL that returns, for each month and tier, the number of subscriptions and the share that renewed to the same channel the following month.

Twitch
Data Manipulation (SQL/Python)
Data Scientist
Twitch
November 29, 2026
Data Scientist
Phone Screen
Data Manipulation (SQL/Python)
Easy

0

0

0 solved


Given `subscriptions(user_id, channel_id, tier, period_month)` with one row per user, channel and paid month, write SQL that returns, for each month and tier, the number of subscriptions and the share that renewed to the same channel the following month.

Subscriptions to creators come in tiers and are a core revenue line for both Twitch and streamers, so renewal is one of the first metrics a data scientist touches. A phone screen uses this to check self-joins on a shifted month, correct denominators, and handling of the most recent incomplete month.

What the Interviewer Expects
  • Self-joins on user, channel, and next month
  • Uses a LEFT JOIN so non-renewals stay in the denominator
  • Attributes the row to the tier in the starting month
  • Excludes the latest month, which cannot have a next month yet
  • Explains tier changes (upgrade or downgrade) still count as renewal
Key Topics to Cover
Self join
LEFT JOIN
Date arithmetic
Cohort metric
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 separate gifted subs from self-paid subs?
  • How would you compute renewal for multi-month prepaid subs?
  • How would you report renewal for a specific creator with tiny numbers?
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

period_month is the first day of the month the sub covers. One row per (user, channel, month). Tier values like '1000', '2000', '3000'. Renewal means the same user has a row for the same channel in ...

Approach

Join each month's row to the row one month later for the same user and channel with a LEFT JOIN. Count all rows in the starting month as the denominator and matched rows as the numerator, grouped by t...


Submit Your Answer
Markdown supported

Related Questions