PRO SQL Modules
SQL Basics1h 20m • 4 lessons
Multiple Tables1h 40m • 5 lessons
Query Restructuring40m • 2 lessons
Data Transformation1h 40m • 5 lessons
Analytical SQL2h • 6 lessons
BETWEEN

Dan Lee
Lesson Objectives
By the end of this lesson, you will:
- Learn how to filter numeric and date ranges using BETWEEN
- Understand how BETWEEN simplifies range conditions compared to multiple comparisons
- Write SQL queries to find Netflix series within a specific release year or rating range
🎬 Scenario: Finding Mid-Range Netflix Releases
Your manager at Netflix, Alex, is analyzing mid-era releases and wants to focus on shows released between 2015 and 2020.
Alex asks:
Can you retrieve all Netflix series that were released between 2015 and 2020?
Your task is to query the netflix_series table and provide the requested data.
series_id | title | genre | release_year | seasons | rating | total_views_millions |
---|---|---|---|---|---|---|
1 | Stranger Things | Sci-Fi | 2016 | 4 | 8.7 | 140 |
2 | Squid Game | Thriller | 2021 | 1 | 8 | 200 |
3 | The Witcher | Fantasy | 2019 | 3 | 7.9 | 90 |
4 | Money Heist | Crime | 2017 | 5 | 8.2 | 180 |
5 | Dark | Sci-Fi | 2017 | 3 | 8.8 | 85 |
1. Filtering Data with BETWEEN
The BETWEEN operator filters results within a specified range, including both the lower and upper values.
Syntax
1SELECT column1, column2
2FROM table_name
3WHERE column_name BETWEEN value1 AND value2;
- BETWEEN value1 AND value2 includes both value1 and value2 in the result.
- It’s equivalent to: WHERE column_name >= value1 AND column_name <= value2;
2. Using BETWEEN for Release Year Filtering
Instead of writing:
1SELECT title, release_year
2FROM netflix_series
3WHERE release_year >= 2015 AND release_year <= 2020;
You can write:
1SELECT title, release_year
2FROM netflix_series
3WHERE release_year BETWEEN 2015 AND 2020;
title | release_year |
---|---|
Narcos | 2015 |
Stranger Things | 2016 |
The Crown | 2016 |
Money Heist | 2017 |
Dark | 2017 |
The Witcher | 2019 |
Bridgerton | 2020 |
What’s Happening?
- BETWEEN 2015 AND 2020 filters results to only include release years from 2015 to 2020.
- The same query using >= and <= would be longer and harder to read.
3. Using BETWEEN for Ratings
You can also apply BETWEEN to numeric values like ratings.
Example Query: Finding Shows with Ratings Between 8.0 and 9.0
1SELECT title, rating
2FROM netflix_series
3WHERE rating BETWEEN 8.0 AND 9.0;
title | rating |
---|---|
“Stranger Things” | 8.7 |
“Squid Game” | 8 |
“Money Heist” | 8.2 |
“Dark” | 8.8 |
“Narcos” | 8.8 |
“The Crown” | 8.6 |
“Black Mirror” | 8.8 |
What’s Happening?
- BETWEEN 8.0 AND 9.0 filters results to only include shows with ratings between 8.0 and 9.0.
- The query still includes 8.0 and 9.0.
✍️ SQL Exercises
Exercise 1: Finding Shows Released Between 2015 and 2020
Alex wants a report showing all series released between 2015 and 2020, sorted by release_year in ascending order, then title in ascending order.
Filter condition:
- release_year must be between 2015 and 2020.
- Sort by release_year in ascending order, then title in ascending order.
title | release_year |
---|---|
Narcos | 2015 |
Stranger Things | 2016 |
The Crown | 2016 |
Money Heist | 2017 |
Dark | 2017 |
The Witcher | 2019 |
Bridgerton | 2020 |
Write an SQL query to return the requested data.
Exercise 2: Finding Shows with Ratings Between 8.0 and 9.0
Alex wants to focus on highly-rated Netflix shows that have ratings between 8.0 and 9.0.
Filter condition:
- rating must be between 8.0 and 9.0.
- Sort by rating in ascending order, then title in ascending order.
title | rating |
---|---|
“Squid Game” | 8 |
“Money Heist” | 8.2 |
“The Crown” | 8.6 |
“Stranger Things” | 8.7 |
“Black Mirror” | 8.8 |
“Dark” | 8.8 |
“Narcos” | 8.8 |
Write an SQL query to return the requested data.