Week-N Retention Curves for New Pinners by Signup Cohort

Last updated: November 29, 2026

Quick Overview

Given users(user_id, signup_date) and activity(user_id, activity_date), compute for each weekly signup cohort (weeks starting Monday) the share of users active in their week 1 and week 2 after signup, where week N covers days 7N to 7N+6 after signup.

Pinterest
Data Manipulation (SQL/Python)
Data Scientist
Pinterest
November 29, 2026
Data Scientist
Onsite
Data Manipulation (SQL/Python)
Medium

0

0

0 solved


Given users(user_id, signup_date) and activity(user_id, activity_date), compute for each weekly signup cohort (weeks starting Monday) the share of users active in their week 1 and week 2 after signup, where week N covers days 7N to 7N+6 after signup.

Activation and retention of new Pinners is a core growth metric, and cohort tables are how growth teams compare onboarding changes. The interviewer looks for a correct cohort denominator, user-relative week buckets, and awareness of incomplete cohorts at the right edge of the table.

What the Interviewer Expects
  • Defines week N relative to each user's own signup date, not the calendar
  • Keeps the denominator as the full cohort, including users with no activity
  • Counts distinct users per week bucket
  • Uses LEFT JOIN so empty cohorts are not dropped
  • Flags right-censored cohorts that have not yet had a full week 2
Key Topics to Cover
retention
cohort analysis
date arithmetic
conditional aggregation
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 make this a rolling 'active in any of days 7 to 13' versus a calendar-week metric?
  • How would you show which onboarding variant each cohort got?
  • Retention dipped for one cohort; how would you check whether it is real or a logging issue?
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
  • One users row per user; activity can have many rows per day (we dedupe).
  • Cohort week = Monday on or before signup_date.
  • week_n = floor((activity_date - signup_date) / 7). Week 0 is the signup we...
Approach

Build a cohort row per user, compute each active user's week_n relative to signup, dedupe to (user, week_n), and then compute conditional distinct counts per cohort divided by cohort size. The cohort ...


Submit Your Answer
Markdown supported