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 Content by Watch Time
00:00
5 left

Top Content by Watch Time

MediumSQL · PostgreSQL

Problem

Disney+ Hotstar's Product Analytics team wants to identify the strongest-performing content in January 2026. Write a PostgreSQL query that ranks content within each content type using watch-time metrics.

Requirements

  1. Join the content catalog to viewing sessions and include only sessions from January 2026.
  2. Calculate total watch minutes and average completion percentage for each content item. Treat NULL watch minutes as zero.
  3. Use a window function to rank content separately within each content_type.
  4. Return the top two content items per content type, ordered by content type and rank.

Schema

content
ColumnTypeDescription
content_idPKINTEGERUnique content identifier
titleVARCHAR(150)Content title
content_typeVARCHAR(30)Content category
viewing_sessions
ColumnTypeDescription
session_idPKINTEGERUnique viewing session identifier
content_idINTEGERWatched content identifier
watched_atDATEDate of the viewing session
watch_minutesINTEGERMinutes watched in the session
completion_pctINTEGERPercentage of content completed
Tablescontentviewing_sessions
Interviewer

Your question is Top Content by Watch Time. Start with the requirements and the two 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.