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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
SQL: 30-Day Stickiness for Reels Feature
00:00
5 left

SQL: 30-Day Stickiness for Reels Feature

HardSQL · PostgreSQL

Problem

Meta's Product Growth team wants to measure 30-day stickiness for a new Instagram Reels feature. Treat a user as an adopter on the date of their first feature_open event for reels_new_editor.

Write a PostgreSQL query that measures D30 feature retention for adopter cohorts from April 1 through April 5, 2025.

Requirements

  1. Count unique adopters by their first feature adoption date.
  2. Count adopters who have a feature_open or reels_save event exactly 30 days after adoption.
  3. Calculate stickiness_pct as retained adopters divided by cohort adopters, expressed as a percentage.
  4. Exclude incomplete cohorts by limiting adoption dates to April 1 through April 5, and order results by cohort date.

Output details

  • Return columns in this order: cohort_date, cohort_users, retained_d30, and stickiness_pct.
  • Order rows by cohort_date ascending.
  • Consider feature events only when event_date is on or after the user's signup_date.
  • Require D30 events to have feature_name equal to reels_new_editor.
  • Count each adopter at most once for D30 retention, even with multiple qualifying events.
  • Round stickiness_pct to two decimal places.

Schema

users
ColumnTypeDescription
user_idPKINTMeta user identifier
signup_dateDATEDate the user joined Meta
reels_feature_events
ColumnTypeDescription
event_idPKINTUnique event identifier
user_idINTUser who generated the event
event_dateDATECalendar date of the event
feature_nameVARCHAR(100)Instagram Reels feature identifier
event_nameVARCHAR(50)Recorded feature action
Tablesusersreels_feature_events
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the two tables are in the Question tab.

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.