Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
SQL: DAU/MAU Ratio
00:00
5 left

SQL: DAU/MAU Ratio

MediumSQL · PostgreSQL

Problem

Meta's Product Growth team uses the AARRR funnel to monitor activation and retention across Instagram Reels, Facebook Groups, and Instagram Save activity. Write a PostgreSQL query that calculates the daily DAU/MAU ratio for the fixed 30-day period from 2025-03-01 through 2025-03-30.

Requirements

  1. Count distinct active users with at least one valid activity event per calendar day as dau.
  2. Count distinct active users with activity during the trailing 30-day period ending on each calendar day as mau.
  3. Return every calendar date in the reporting window, including dates with zero DAU.
  4. Calculate dau_mau_ratio as DAU divided by MAU, rounded to four decimal places. Avoid division by zero.

Schema

users
ColumnTypeDescription
user_idPKVARCHAR(20)Meta user identifier
account_statusVARCHAR(20)Current account state
signup_dateDATEAccount creation date
app_activity_events
ColumnTypeDescription
event_idPKINTUnique activity event identifier
user_idVARCHAR(20)User associated with the event
event_dateDATECalendar date of the event
surfaceVARCHAR(30)Meta product surface
event_nameVARCHAR(30)Recorded activity type
Tablesusersapp_activity_events
Interviewer

Your question is SQL: DAU/MAU Ratio. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.