Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Reels Cohort 7-Day Rolling Retention
00:00
5 left

Reels Cohort 7-Day Rolling Retention

HardSQL · PostgreSQL

Problem

Meta’s Instagram Reels team wants a cohort view of retention. Write a SQL query to calculate the 7-day rolling retention rate for Instagram users, segmented by the calendar week of their first Reels use.

Rolling retention here means: for each user, check whether they had any Instagram activity on or after day 7 from their first Reels use date. Then compute the share of retained users within each first-Reels week cohort.

Requirements

  1. Identify each user’s first Reels use date from reels_events.
  2. Bucket users into cohorts using DATE_TRUNC('week', first_reels_date).
  3. A user is retained if they have at least one row in ig_activity where activity_date >= first_reels_date + INTERVAL '7 days'.
  4. Return, for each cohort week:
    • cohort week
    • cohort size
    • retained users
    • 7-day rolling retention rate
  5. Exclude rows where event_type is not a real Reels use event.

Schema

reels_events
ColumnTypeDescription
event_idPKINTPrimary key for each Reels event
user_idINTInstagram user identifier
event_dateDATEDate the Reels event occurred
event_typeVARCHAR(50)Type of Reels event such as reels_play or reels_impression
surfaceVARCHAR(50)Meta surface where the event was logged
ig_activity
ColumnTypeDescription
activity_idPKINTPrimary key for each Instagram activity event
user_idINTInstagram user identifier
activity_dateDATEDate of user activity
activity_typeVARCHAR(50)Instagram activity type such as app_open, like, or ig_save
surfaceVARCHAR(50)Surface where the activity occurred
Tablesreels_eventsig_activity
Interviewer

Your question is Reels Cohort 7-Day Rolling Retention. Start with the requirements and the two tables in the Question tab.

Run and submit as often as you like. When you're ready, talk me through your approach or go straight to the code.

You need to log in / sign up to run or submit.
CodePostgreSQL
Sign up free to run your codeLog inLn 1
Run your query to see results here.