Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

Daily Active Users and Churn

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

Your question is Daily Active Users and Churn. 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

Wish wants a daily engagement report for users interacting with the Wish marketplace. Using the tables below, write a PostgreSQL query for activity from January 1 through January 5, 2025.

Requirements

  1. Return one row for every date in the reporting period, including dates with no activity.
  2. Calculate daily_active_users as the distinct number of registered users with at least one activity event on that date.
  3. Calculate daily_churned_users as users active on the previous day who have no activity on the current day. Do not count users who were not active on the previous day.
  4. Return rows ordered chronologically by activity_date.

Deduplicate multiple activity events from the same user on the same date before calculating either metric.

Schema

users
ColumnTypeDescription
user_idPKINTEGERUnique Wish user identifier
display_nameVARCHAR(100)User display name
activity
ColumnTypeDescription
activity_idPKINTEGERUnique activity event identifier
user_idINTEGERUser associated with the activity event
activity_dateDATECalendar date of the activity event
event_typeVARCHAR(40)Type of marketplace activity
Tablesusersactivity
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results