Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

SQL for DAU and Retention

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

Your question is SQL for DAU and Retention. 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

Scopely's Monopoly GO! analytics team needs a daily engagement report. Write a PostgreSQL query that calculates DAU and install-cohort retention using UTC event dates.

Requirements

  1. Count each player once per calendar day when they have at least one session event.
  2. Return DAU for each player install date, including install dates with zero DAU.
  3. Calculate D1 and D7 retention rates for each install-date cohort as percentages, rounded to two decimals.
  4. Return one row per install date, ordered chronologically.

Schema

players
ColumnTypeDescription
player_idPKINTUnique player identifier
install_dateDATEUTC installation date
platformVARCHAR(20)Player device platform
game_events
ColumnTypeDescription
event_idPKINTUnique event identifier
player_idINTPlayer who generated the event
event_tsTIMESTAMPUTC event timestamp
event_typeVARCHAR(30)Event classification
Tablesplayersgame_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results