Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
Get started
DAU by Video Categories
00:00
5 left

DAU by Video Categories

MediumSQL · PostgreSQL

Problem

Write a SQL query to find the daily active users who watched at least three different video categories yesterday on YouTube.

Use the provided watch, video, category, and user data. Treat the current date as the database session date, and include watches from the previous calendar day only.

Output

  1. One row per qualifying user.
  2. Include user_id, username, and category_count.
  3. Return users with at least three distinct categories, ordered by user_id ascending.

Schema

users
ColumnTypeDescription
user_idPKINTUnique YouTube user identifier
usernameVARCHAR(100)Display name of the user
categories
ColumnTypeDescription
category_idPKINTUnique video category identifier
category_nameVARCHAR(100)Name of the video category
videos
ColumnTypeDescription
video_idPKINTUnique YouTube video identifier
video_titleVARCHAR(200)Title of the video
category_idINTCategory assigned to the video
watch_events
ColumnTypeDescription
watch_idPKINTUnique viewing event identifier
user_idINTUser who watched the video
video_idINTVideo that was watched
watched_atTIMESTAMPTimestamp when the watch occurred
Tablesusersvideoscategorieswatch_events
Interviewer

Your question is DAU by Video Categories. Start with the requirements and the four 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.