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
ExperiencesCoaching
New
Practice
Mock InterviewsTimed interview simulations with feedbackSuccess 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
Get started
Top 10 Shows by Region
00:00
5 left

Top 10 Shows by Region

MediumSQL · PostgreSQL

Problem

Write a SQL query to identify the top 10 most-watched shows in a specific region for the last month.

Use India as the target region. Treat total watch minutes as the measure of being most-watched, and consider viewing events from the previous calendar month only.

Output

  1. One row per qualifying show with show_title, total_watch_minutes, and watch_sessions.
  2. Include only shows viewed in India during the previous calendar month.
  3. Order by total_watch_minutes descending, then show_id ascending to break ties. Return at most 10 rows.

Output details

  • Treat DATE '2026-09-15' as today's date.
  • Treat NULL watch_minutes as 0 when summing, and count every qualifying viewing-event row as a watch_session without deduplication.

Schema

viewing_events
ColumnTypeDescription
event_idPKINTUnique viewing event identifier
show_idINTViewed show identifier
region_idINTViewer region identifier
viewed_atTIMESTAMPTimestamp when viewing occurred
watch_minutesINTMinutes watched during the event
shows
ColumnTypeDescription
show_idPKINTUnique show identifier
show_titleVARCHAR(150)Disney+ Hotstar show title
languageVARCHAR(50)Primary show language
regions
ColumnTypeDescription
region_idPKINTUnique region identifier
region_nameVARCHAR(80)Market or geographic region name
Tablesviewing_eventsshowsregions
Interviewer

Whenever you're ready, walk me through your approach or go straight to the code. The requirements and the three tables are in the Question tab.

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.