Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started

DAU by Content Category

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

Your question is DAU by Content Category. 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

Disney+ Hotstar wants to monitor daily active users for its Sports content category. Write a PostgreSQL query that counts unique users who watched at least one Sports title during January 1 through January 3, 2025.

Requirements

  1. Join viewing events to the content catalog using content_id.
  2. Keep only events for content where category = 'Sports' and timestamps fall within the specified date range.
  3. Return one row per viewing date with the number of distinct non-null users, ordered chronologically.

Repeated viewing events by the same user on the same day must count once. Events for other categories, unknown content IDs, null users, and timestamps outside the date range must not contribute to DAU.

Schema

content_catalog
ColumnTypeDescription
content_idPKINTUnique identifier for a Disney+ Hotstar content title
content_titleVARCHAR(150)Display title of the content
categoryVARCHAR(50)Content category, such as Sports or Drama
viewing_events
ColumnTypeDescription
event_idPKINTUnique identifier for a viewing event
user_idVARCHAR(20)Identifier of the viewer
content_idINTIdentifier of the watched catalog title
event_tsTIMESTAMPTZTimestamp at which the viewing event occurred
Tablescontent_catalogviewing_events
Your solutionPostgreSQL
You need to log in / sign up to run or submit.
Run a query to see results