11th Dec 2024 7 minutes read Netflix Wrapped With SQL: Let’s Dive Into Your Streaming Year Jakub Romanowski PostgreSQL Data Analysis SQL Practice Table of Contents Step 1: Grab Your Netflix Data Step 2: Load It Into PostgreSQL (The Fun Way) Step 3: See What Series Was The Most Watched Step 4: Spot Trends Over The Year Step 5: Uncover Surprising Patterns Netflix Wrapped Using SQL In this article, we’re turning your Netflix viewing history into your very own Netflix Wrapped, using SQL. Ever wondered what show you binged the hardest or which day you couldn’t resist pressing play? I’ll show you how to pull all those fun insights. Let’s dig in! Hey! The year’s almost over, so why not take a fun look back at your Netflix habits? Remember all those weekends you said you’d "watch just one episode"? Yeah, me too. With SQL, you can turn your Netflix viewing history into cool insights, like finding your most-watched shows or uncovering your binge-watching patterns. It’s easier than you think and, honestly, pretty fun to see the data laid out! If this sounds like your kind of thing, you might also enjoy checking out my other article on how to analyze your Spotify Wrapped data with SQL. But let's get back to movies and series. Step 1: Grab Your Netflix Data First things first—you need your Netflix viewing history. This is where it all begins! You’re going to download the data Netflix has been quietly keeping on everything you’ve watched. Here’s what you need to do: Log into Netflix in your browser (trust me, it’s way easier this way). Click on Account Settings (it’s under your profile picture). Go to Profile & Parental Controls, pick your profile, and click Viewing activity. Scroll to the bottom and hit Download all. Boom! You’ve got a CSV file with everything you’ve watched. Got it? Sweet! Let’s move on. Step 2: Load It Into PostgreSQL (The Fun Way) PostgreSQL is a powerful open-source relational database system that’s perfect for handling structured data—like your Netflix viewing history. It’s reliable, versatile, and widely used in everything from personal projects to enterprise applications. To make things even easier, we’ll use pgAdmin, a friendly graphical interface for managing PostgreSQL databases. Think of pgAdmin as your command center: it lets you create databases, run queries, and visualize data without needing to memorize a ton of SQL commands. If you’re new to these tools, check out this beginner’s guide: How to Install and Set Up PostgreSQL with pgAdmin. This guide will walk you through the entire process, making it super easy to get started. Now, let’s get your data into PostgreSQL so we can start playing with it. Here’s the deal: Open pgAdmin and connect to your PostgreSQL server. Add a table for your data by writing this query in Query tool: CREATE TABLE NetflixViewingHistory ( Title TEXT, Date DATE ); Import your CSV file: Right-click the table and select Import/Export. Choose your CSV file, map the columns to Title and Date, and click OK. Want to get fancy? You can also import data with an SQL query: COPY NetflixViewingHistory(Title, Date) FROM '/path/to/your/NetflixViewingHistory.csv' DELIMITER ',' CSV HEADER; Just replace /path/to/your/NetflixViewingHistory.csv with the real file path. And just like that, your data is ready to go! To verify the data and make sure everything loaded correctly, you can run a simple SQL query to check your table: SELECT * FROM NetflixViewingHistory LIMIT 10; This will display the first 10 rows of your table. If you see your shows, dates, and details neatly in columns, you’re good to go! Step 3: See What Series Was The Most Watched Alright, let’s figure out what series kept you glued to the screen this year. Instead of just looking at all titles, this query focuses on finding the most-watched series by grouping episodes together. By running this query, you’ll uncover the shows that dominated your Netflix time. This query counts how many episodes you watched from each series, giving you a clear winner for your most-watched series. Was it Friends? Maybe Stranger Things? Let’s take a look: SELECT SPLIT_PART(Title, ':', 1) AS Series, COUNT(*) AS WatchCount FROM NetflixViewingHistory GROUP BY Series ORDER BY WatchCount DESC LIMIT 10; This query gives you a list of your most-watched series. In my results, "Friends" took the top spot, with "The Office" and "Dr House" close behind. Other popular choices for me included “Vikings", "Breaking Bad", and "Cobra Kai". Even "Designated Survivor" and "Fauda" made the list, showing a pretty eclectic mix! Now it’s your turn. What does your list look like? Did your all-time favorite series make the cut, or was there a surprise contender at the top? Give it a try and let me know! Step 4: Spot Trends Over The Year Let’s get nerdy with some monthly stats to uncover your viewing trends. Did you watch more during the cozy winter months, or was summer your Netflix binge season? By using SQL, we can break down your viewing history month by month to see how your habits changed throughout the year. Here’s a pretty cool SQL query for you: SELECT EXTRACT(YEAR FROM Date) AS Year, EXTRACT(MONTH FROM Date) AS Month, COUNT(*) AS TotalViews FROM NetflixViewingHistory GROUP BY Year, Month ORDER BY Year DESC, Month DESC; This query will give you a month-by-month breakdown of how many shows or movies you watched. For example, you might notice a spike in December thanks to holiday specials or in July during those lazy summer evenings. In my case, December was off the charts—clearly, a month full of cozy movie nights. Want to know which month in 2024 had the most views overall? Try this query: SELECT EXTRACT(MONTH FROM Date) AS Month, COUNT(*) AS TotalViews FROM NetflixViewingHistory WHERE EXTRACT(YEAR FROM Date) = 2024 GROUP BY Month ORDER BY TotalViews DESC LIMIT 1; This query identifies the single busiest month in 2024. For me, February was the clear winner—I managed to watch an impressive 77 shows and movies! It seems those cozy winter evenings were perfect for Netflix marathons. But what movie or series was the most popular among those February binges? Let’s find out with this query: SELECT SPLIT_PART(Title, ':', 1) AS Series, COUNT(*) AS TotalViews FROM NetflixViewingHistory WHERE EXTRACT(YEAR FROM Date) = 2024 AND EXTRACT(MONTH FROM Date) = 2 GROUP BY Series ORDER BY TotalViews DESC; These queries will show your favorite title and most-watched series for February. In my case, most of the 77 watches were episodes of "Dr. House" and "Yellowstone." What about you? Was it an iconic series or a comfort movie you kept returning to? Check your results! Step 5: Uncover Surprising Patterns Want to know your go-to Netflix day? Let’s uncover the day of the week when you’re most likely to press play. SQL can easily reveal this by analyzing your viewing history and counting how many shows or movies you watched each day of the week. It’s a fun way to spot your streaming patterns! SELECT CASE EXTRACT(DOW FROM Date) WHEN 0 THEN 'Sunday' WHEN 1 THEN 'Monday' WHEN 2 THEN 'Tuesday' WHEN 3 THEN 'Wednesday' WHEN 4 THEN 'Thursday' WHEN 5 THEN 'Friday' WHEN 6 THEN 'Saturday' END AS DayOfWeek, COUNT(*) AS Views FROM NetflixViewingHistory GROUP BY DayOfWeek ORDER BY Views DESC; For me, the result was pretty obvious—weekends dominated my Netflix time! Sundays and Saturdays were my prime binge days. What about you? Did weekends take the crown, or do you find yourself streaming more during the week? SQL makes it easy to uncover your unique habits and reveal interesting patterns in your viewing history. Give it a try and see what your data says! Netflix Wrapped Using SQL You did it! You’ve just turned your Netflix viewing history into your very own Netflix Wrapped using SQL. Isn’t it amazing to see all those stats laid out? From finding your most-watched series to spotting your favorite binge days, you’ve got a full snapshot of your streaming habits. You already know my stats—now it’s time for yours! What do your results look like? Did a surprise series take the top spot, or was your busiest month a shocker? Whatever your story, SQL makes it easy to uncover and share! If this was fun (and let’s be real, it totally was), you should check out the SQL From A to Z track. It’s packed with seven awesome courses that teach you everything from basic queries to more advanced skills like joins, aggregations, and subqueries. It’s interactive, practical, and builds your skills step by step—kind of like we just did, but on a whole new level. Trust me, this track is the perfect next step if you’re ready to level up your SQL game. Who knows? Next year, you could be using SQL to analyze everything from your fitness progress to your travel plans. Happy streaming—and querying. Tags: PostgreSQL Data Analysis SQL Practice