Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Meta Signup Month Retention Cohorts

HardSQL · PostgreSQL00:00
Practice interviewer
In session
5 left
00:00

Your question is Meta Signup Month Retention Cohorts. Start with the requirements and the two tables on the right.

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.

Problem

Meta’s marketing analytics team wants a monthly cohort retention view for new user signups. Write a SQL query to measure how many users returned in each month after their signup month.

Requirements

  1. Define each user’s cohort as the month of their signup_date from the facebook_users table.
  2. Treat a user as retained in a month if they have at least one event in facebook_activity during that calendar month.
  3. Return one row per signup_month and months_since_signup.
  4. Include:
    • signup_month
    • months_since_signup where signup month is 0, the next month is 1, etc.
    • cohort_size
    • retained_users
    • retention_rate rounded to 4 decimal places
  5. Only count activity on or after the user’s signup month. Ignore activity with a NULL activity_date.
  6. Order results by signup_month, then months_since_signup.

Schema

facebook_users
ColumnTypeDescription
user_idPKINTUnique user identifier
signup_dateDATEDate the user signed up
acquisition_channelVARCHAR(50)Marketing acquisition source
facebook_activity
ColumnTypeDescription
activity_idPKINTUnique activity identifier
user_idINTUser who generated the activity
activity_dateDATEDate of the activity
surface_nameVARCHAR(50)Meta surface where activity happened
Tablesfacebook_usersfacebook_activity
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results