Last Chance to Join Data Science Interview MasterClass (this week) 🚀 | Just 2 spots remaining...

PRO SQL Modules

SQL Basics
1h 20m • 4 lessons
  1. SQL SELECT
  2. LIMIT
  3. ORDER BY
  4. DISTINCT
Data Filtering
1h 20m • 4 lessons
  1. WHERE
  2. LIKE
  3. IN
  4. BETWEEN
Aggregations
40m • 2 lessons
  1. GROUP BY
  2. HAVING
Multiple Tables
1h 40m • 5 lessons
  1. INNER JOIN
  2. LEFT & RIGHT JOIN
  3. FULL OUTER JOIN
  4. SELF JOIN
  5. INTERSECT & EXCEPT
Query Restructuring
40m • 2 lessons
  1. Subquery
  2. Common Table Expressions (CTE)
Data Transformation
1h 40m • 5 lessons
  1. CASE
  2. String
  3. Date Manipulation
  4. Math Operations
  5. COALESCE
Analytical SQL
2h • 6 lessons
  1. Ranking - ROW_NUMBER(), RANK(), DENSE_RANK()
  2. Running Totals
  3. LAG and LEAD
  4. FIRST_VALUE, LAST_VALUE, Nth_VALUE
  5. PARTITION BY
  6. SQL BETWEEN and PRECEDING
Unlock Premium
FREE

SQL SELECT

Course Author Daniel Lee
Instructor

Dan Lee

Learn SQL for free with interactive exercises designed to help aspiring Data Engineers, Data Analysts, and Data Scientists. Learn the basics and advanced SQL concepts by solving real-world problems from MANGO (Meta, Amazon, Netflix, Google, OpenAI)

Lesson Objectives

By the end of this lesson, you will:

  • Understand how to retrieve data using SELECT
  • Learn how to specify columns and use aliases (AS)
  • Write your first SQL query using Netflix’s hit series data

🎬 Scenario: Analyzing Netflix Hit Series

You’ve just been hired as a Data Analyst at Netflix! Your first task is to extract insights on the platform’s most successful series.

Your manager, Alex, has asked:

We need a report on our top-performing series, including their ratings, genres, and total viewership. Can you retrieve this data?

To get started, take a look at the netflix_series table, which contains key details:

series_idtitlegenrerelease_yearseasonsratingtotal_views_millions
1Stranger ThingsSci-Fi201648.7140
2Squid GameThriller202118.0200
3The WitcherFantasy201937.990
4Money HeistCrime201758.2180
5DarkSci-Fi201738.885
6BridgertonDrama202027.3100
7Breaking BadCrime200859.5120
8NarcosCrime201538.875
9The CrownDrama201658.695
10Black MirrorSci-Fi201168.8110

1. The Basics: SELECT *

The SELECT statement is the foundation of SQL. It’s how we retrieve data from a database.

Syntax

1SELECT * FROM table_name;

Example Query

1SELECT * FROM netflix_series;

Output Example

series_idtitlegenrerelease_yearseasonsratingtotal_views_millions
101Stranger ThingsSci-Fi201648.7140
102Squid GameThriller202118.0200
103The WitcherFantasy201937.990
104Money HeistCrime201758.2180
…………………

What’s Happening?

  • SELECT * means “Show me everything in this table.”
  • While SELECT * works, in real-world data analysis, we often only need specific columns.

2. Selecting Specific Columns

Instead of retrieving all columns, you can specify which columns you need.

Syntax

1SELECT column1, column2 FROM table_name;

Example Query

1SELECT title, genre, rating FROM netflix_series;

Output Example

titlegenrerating
Stranger ThingsSci-Fi8.7
Squid GameThriller8.0
The WitcherFantasy7.9
Money HeistCrime8.2
………

Why is this better than SELECT *?

  • Faster Execution – Only pulls needed columns, reducing unnecessary data.
  • More Readable – Avoids cluttering the results with extra columns.

3. Using Aliases (AS) for Readability

Your manager wants to create a report where column names are more readable.
SQL allows you to rename columns using AS.

Syntax

1SELECT column_name AS new_name FROM table_name;

Example Query

1SELECT title AS "Show Name", 
2       genre AS "Category", 
3       rating AS "IMDb Score"
4FROM netflix_series;

Output Example

Show NameCategoryIMDb Score
Stranger ThingsSci-Fi8.7
Squid GameThriller8.0
The WitcherFantasy7.9
Money HeistCrime8.2
………

Why Use Aliases?

  • Makes reports more readable for non-technical users.
  • Useful when working with complex queries that involve calculations or joins.

✍️ SQL Exercises

Exercise 1: Renaming Columns for a Netflix Series Report

Your manager wants a list of Netflix series along with their release year and total viewership. However, the column names should be more readable for a company report.

Rename the columns as follows:

  • title → “Series Name”
  • release_year → “Years Released”
  • total_views_millions → “Total Views (Millions)”

Write an SQL query to retrieve the requested data.

Expected Output:

Series NameYears ReleasedTotal Views (Millions)
Stranger Things2016140
Squid Game2021200
The Witcher201990
Money Heist2017180
Dark201785
Bridgerton2020100
Breaking Bad2008120
Narcos201575
The Crown201695
Black Mirror2011110

Write an SQL query to return the requested data.

Upgrade to Pro
👉 Found this lesson helpful?