TGViewer
Data Analyst Interview Resources Data Analyst Interview Resources @dataanalystinterview · 52.6K subscribers
Post #2418 1.41K
🔥 SQL Interview Question of the Day

📌 Scenario:

A streaming platform wants to find the most watched movie in each genre.

You have one table:

watch_history

• user_id
• movie_id
• movie_name
• genre
• watch_time_minutes

☑ Solution:

SELECT
genre,
movie_name,
total_watch_time
FROM (
SELECT
genre,
movie_name,
SUM(watch_time_minutes) AS total_watch_time,
RANK() OVER (
PARTITION BY genre
ORDER BY SUM(watch_time_minutes) DESC
) AS rnk
FROM watch_history
GROUP BY genre, movie_name
) t
WHERE rnk = 1;

💡 Concept Tested:

Window Functions + RANK() + GROUP BY + Aggregate Functions

❤️ React if you want more SQL interview questions.
  • ❤ 8
More from @dataanalystinterview
  1. Oct 1, 2026🔥 Top 10 Theoretical Interview Questions Every Data Analyst Must Prepare 📊 Data Analyst…
  2. Sep 29, 2026🚀 Excel Formulas Fundamentals — Part 10 📊 Conditional Functions (SUMIF, SUMIFS, COUNTIF,…
  3. Sep 29, 2026𝗙𝗥𝗘𝗘 𝗥𝗲𝘀𝗼𝘂𝗿𝗰𝗲𝘀 𝗧𝗼 𝗟𝗲𝗮𝗿𝗻 𝗔𝗜 𝗶𝗻 𝟮𝟬𝟮𝟲🚀 ​ Explore 6 free resource…
  4. Sep 29, 2026📊 Tableau Learning Roadmap — Part 2 Connecting to Data Before creating visualizations in…
  5. Sep 28, 2026This is useful when you want to guide someone through an analytical narrative. The Tableau…
  6. Sep 28, 2026📊 Tableau Learning Roadmap — Part 1 What is Tableau? Tableau is a Business Intelligence a…
Threads Profile ViewerView any public Threads profile without an account.Open ThreadLook →Writing with AI? Make it sound human.Metric37 rewrites AI drafts so they read naturally. Free AI detector, 1,500 words free.Try Metric37 →