Dataford
Interview QuestionsInterview GuidesExperiencesCoaching
New
Pricing
Get started
Dataford
Popular roles
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Browse
Browse All RolesEvery role hub, from analyst to MLBrowse All CompaniesCompany-specific interview loopsAll Interview GuidesThe full guide library
Top questions by role
Software EngineerData AnalystData ScientistData EngineerBusiness AnalystAI EngineerMachine Learning EngineerProduct Manager
Top questions by skill
SQLPythonStatisticsMachine LearningA/B TestingSystem DesignGenerative AIProduct SenseMetricsBehavioral
Browse all questions →Try a mock interview
Experiences
Practice
Mock InterviewsTimed interview simulations with feedbackCoaching1:1 coaching with people at your target companiesSuccess PathYour 6-week structured planModulesCurated lessons by topicWebinarsTalks from ex-Big Tech data leadsPlaygroundA free-form scratch editor
Learn
BlogInterview strategy and career adviceTech Job Market ReportHiring trends across data and AI rolesFor UniversitiesDataford for career centersAbout DatafordWho we are and how we build
Pricing
Build my plan
Top Genres by Demographic
00:00
5 left

Top Genres by Demographic

MediumSQL · PostgreSQL

Problem

Warner Bros. Discovery wants to compare viewing preferences across user demographic groups. Write a SQL query to find the three most-watched content genres for each demographic group during the 30-day reporting period ending on September 18, 2026.

Output

  1. Return one row per demographic and genre ranking, with columns demographic_group, genre, total_minutes, and genre_rank.
  2. Include only sessions in the reporting period, and exclude rows with a NULL demographic group or genre.
  3. Return up to three genres per demographic, ordered by total watched minutes descending. Break ties alphabetically by genre.
  4. Order the final result by demographic group and genre rank.

Schema

streaming_sessions
ColumnTypeDescription
session_idPKINTUnique streaming session identifier
user_idINTUser associated with the session
content_idINTContent watched during the session
session_startTIMESTAMPSession start timestamp
minutes_watchedINTMinutes watched during the session
users
ColumnTypeDescription
user_idPKINTUnique user identifier
demographic_groupVARCHAR(50)User demographic classification
content
ColumnTypeDescription
content_idPKINTUnique content identifier
content_titleVARCHAR(150)Title of the content
genreVARCHAR(50)Primary content genre
Tablesstreaming_sessionsuserscontent
Interviewer

Your question is Top Genres by Demographic. Start with the requirements and the three 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
Sign up free to run your codeLog inLn 1
Run your query to see results here.