Weekly Listening Retention Of Yandex Music Subscribers By Cohort
Last updated: November 29, 2026
Quick Overview
Using a subscriptions table and a listens table, compute for each weekly signup cohort the share of subscribers who listened at least once in week 0 through week 8 after their own signup date.
Yandex
November 29, 20260
0
0 solved
Using a subscriptions table and a listens table, compute for each weekly signup cohort the share of subscribers who listened at least once in week 0 through week 8 after their own signup date.
Subscription retention is a core metric for Yandex Music and the Plus bundle, and SQL rounds for analytics and data engineering roles check cohort logic carefully. The interviewer looks for correct cohort definition, relative week computation and the right denominator.
What the Interviewer Expects
- Define a user's signup as their first subscription start
- Bucket cohorts by calendar week but measure activity relative to the user's own signup
- Count each user once per relative week
- Divide by the full cohort size, including users who never listened
- Exclude listens before signup
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 treat users who cancel and resubscribe?
- How would you write this efficiently in ClickHouse over billions of listens?
- How do you avoid partially observed weeks for recent cohorts?
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
subscriptions(user_id, started_at, ...) may have several rows per user (renewals, resubscribes). listens(user_id, track_id, played_at) is large. Week n means days [7n, 7n+6] after signup. Cohort =...
Approach
- First subscription per user. 2) Cohort week via
DATE_TRUNC('week', ...)and cohort sizes from that table, so silent users stay in the denominator. 3) Distinct (user, relative week) pairs from lis...