Dataford
Interview QuestionsInterview GuidesExperiencesMock InterviewsPricing
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.

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

Your question is Top 10 Shows by Region. 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
You need to log in / sign up to run or submit.Ln 1
Run your query to see results here.