Compare Classic and Rolling Weekly Retention for Google Photos Uploaders

Last updated: November 29, 2026

Quick Overview

For weekly cohorts of Google Photos uploaders, compute both classic retention (uploaded in exactly week N after first upload) and rolling retention (uploaded in week N or any later week) in one query.

Google
Data Manipulation (SQL/Python)
Data Scientist
Google
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Hard

0

0

0 solved


For weekly cohorts of Google Photos uploaders, compute both classic retention (uploaded in exactly week N after first upload) and rolling retention (uploaded in week N or any later week) in one query.

Photos usage is bursty (vacations, holidays), so a Google product analytics team might prefer rolling retention for it. The onsite interviewer wants you to define both metrics precisely, compute them without an expensive self-join for the rolling one, and explain when each is the right lens.

What the Interviewer Expects
  • Define classic and rolling retention precisely and note rolling is monotone non-increasing
  • Compute rolling retention from each user's first and last active week
  • Compute classic retention by joining activity weeks to cohorts
  • Use an offsets array to produce zero rows rather than missing rows
  • Exclude offsets that land in the incomplete current week
  • Explain the right-censoring bias of rolling retention for recent cohorts
Key Topics to Cover
retention
cohort analysis
rolling retention
GENERATE_ARRAY
right censoring
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
  • Why does rolling retention for a recent cohort keep changing as time passes?
  • How would you report this for 5 years of data cheaply?
  • Which metric would you put on a launch dashboard for a new sharing feature, and why?
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

photos_uploads(user_id, upload_ts, ...), one row per upload event. A user's cohort is the Monday-start week of their first upload. Classic retention at N: share of the cohort with an upload in week ...

Approach

Collapse to distinct user-weeks. Per user, store the first week and last_week_number, the offset of their latest active week. Rolling retention at N is then simply last_week_number >= N, which nee...


Submit Your Answer
Markdown supported