๐Ÿ“š 100 DAYS SQL
CODING CHALLENGE

DAY 16

Netflix Movies Analytics Platform

โœจ Master SQL One Problem at a Time โœจ

๐ŸŽฌ Netflix Movies Analytics

Build a streaming analytics platform with rankings, window functions, complex JOINs, and CTEs.

Table 1: movies (5 of 50 rows)

movie_id title release_year duration_mins language budget_millions revenue_millions
M001 inception2010148 english 160829.9
m002THE DARK KNIGHT2008NULLEnglish1851005.5
M003 parasite 2019132koreanNULL258.8
M004avengers endgame2019181ENGLISH3562798.5
m005Titanic1997195 English 200NULL

...45 more rows in the download!

Table 2: genres

genre_idmovie_idgenre_name
G001M001 Sci-Fi
G002m001action
G003M002ACTION
G004M003thriller

Table 3: actors (5 of 50 rows)

actor_idactor_namebirth_yearnationality
A001leonardo dicaprio1974 american
a002CHRISTIAN BALENULLBritish
A003 Song Kang-ho 1967south korean

Table 4: movie_cast

cast_idmovie_idactor_idrole_typecharacter_name
C001M001 A001 LEADDom Cobb
C002m002a002lead Batman

Table 5: user_ratings (5 of 50 rows)

rating_idmovie_iduser_idratingrating_date
R001M001U1018.52024-01-15
R002m001 U102 9.015/01/2024

๐Ÿ“‹ Your Challenge

Build Netflix analytics with rankings, percentiles, ROI calculations, and complex multi-table JOINs.

๐Ÿงน Data Cleaning:
  • Standardize all IDs (movie_id, actor_id, etc.) - uppercase and trim
  • Clean movie titles - proper case formatting
  • Handle NULL duration (use average: 120 mins)
  • Handle NULL budget/revenue (use median values)
  • Standardize language names - proper case
  • Clean actor names - proper case
๐Ÿ”— Complex JOINs & Aggregations:
  • JOIN movies โ†’ genres (one-to-many relationship)
  • JOIN movies โ†’ movie_cast โ†’ actors (chained JOINs)
  • JOIN movies โ†’ user_ratings
  • Calculate average rating per movie
  • Count distinct genres per movie
  • Count distinct actors per movie
  • Concatenate all genres into single field
๐Ÿ“Š Window Functions & Rankings:
  • RANK movies by revenue (overall ranking)
  • ROW_NUMBER for unique position
  • RANK movies by year (PARTITION BY release_year)
  • Calculate revenue percentile using PERCENT_RANK
  • Calculate rating percentile
  • Running total revenue by year
  • Flag top 3 movies per year
๐ŸŽฏ Advanced Calculations:
  • Calculate ROI: ((revenue - budget) / budget) ร— 100
  • Categorize performance: Blockbuster, Hit, Moderate, Low
  • Categorize ratings: Excellent, Good, Average, Below Average
  • Use CTEs for data cleaning and aggregation
  • Filter movies with revenue > 0

๐Ÿ’ก Key SQL Concepts: RANK, ROW_NUMBER, PERCENT_RANK, PARTITION BY, CTEs, Complex JOINs, GROUP_CONCAT!

๐ŸŽฏ Ready to Solve?

Download the full challenge PDF with complete solution, explanations, and step-by-step hints!

๐Ÿ’ช Keep Practicing!

Master window functions
Build streaming analytics
Rank and analyze with SQL

Day 17 coming tomorrow!

Follow the 100 Days SQL Challenge

Master SQL one problem at a time!

Rahul Kanche โ€” exploring data, decoding clarity!