Top Viewers by Watch Hours
Problem
**[Asked at Netflix]**
Netflix wants to identify its most active subscribers. Given a table of
viewing history and a table of subscribers, find the **top 3 users by
total hours watched** in March 2023.
Return `name` and `total_hours` (rounded to 2 dp),
ordered by total hours descending.
Tables
Example rows — the live problem includes the full dataset.
viewers
| user_id | name | plan |
|---|
watch_history
| watch_id | user_id | show_id | hours_watched | watched_at |
|---|
Expected output
Your answer should return 3 rows with the columns name, total_hours.
Starter code (SQL)
SELECT *
FROM viewers;Solve this SQL question free
Write SQL and run it instantly in your browser — even on your phone. No signup needed to try.
Solution & explanation
Create a free account to unlock the optimal solution, a step-by-step explanation, and the hidden test cases that grade your answer.
Sign up free to unlock