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
Compare Reels Signup Cohort Engagement
00:00
5 left

Compare Reels Signup Cohort Engagement

HardSQL · PostgreSQL

Problem

You are analyzing early engagement for two Instagram Reels signup cohorts in the AARRR funnel. Write a PostgreSQL query to compare users who signed up in January 2024 versus February 2024. For each cohort, return the cohort size, the number of users who had at least one Reels engagement event in their first 14 days after signup, total 14-day Reels engagements, average 14-day engagements per user, and the lift in average engagements versus the previous cohort.

Count only view, like, comment, and save events on the reels surface. A user with no qualifying events should still remain in the cohort denominator.

Output details

  • Return columns in this order: cohort_month, cohort_size, engaged_users_14d, total_engagements_14d, avg_engagements_per_user_14d, prev_cohort_avg, and avg_engagement_lift_vs_prev.
  • Format cohort_month as YYYY-MM and sort cohorts ascending chronologically.
  • Include events on the signup date and exclude events occurring exactly 14 days after signup.
  • Treat users without qualifying events as having 0 engagements, include them in averages, and count them as not engaged.
  • Round avg_engagements_per_user_14d and avg_engagement_lift_vs_prev to 2 decimal places.
  • Return NULL for prev_cohort_avg and avg_engagement_lift_vs_prev when no previous cohort exists.

Schema

users
ColumnTypeDescription
user_idPKINTUnique user identifier
signup_dateDATEDate the user signed up
signup_surfaceVARCHAR(50)Meta surface where the signup originated
country_codeVARCHAR(10)ISO-style country code
engagement_events
ColumnTypeDescription
event_idPKINTUnique event row identifier
user_idINTUser who generated the event
event_dateDATEDate of the engagement event
surfaceVARCHAR(50)Product surface such as reels or fb_groups
event_typeVARCHAR(50)Type of engagement action
event_countINTNumber of actions represented by the event row
Tablesusersengagement_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.