Join ML Engineer Interview MasterClass (April Cohort) led by FAANG Data Scientists | Just 6 seats remaining...
ML Engineer MasterClass (April) | 6 seats left
By the end of this lesson, you will:
Your manager at Netflix, Alex, is analyzing user interest in dark-themed content.
Alex asks:
Can you retrieve all shows that have the word “Dark” anywhere in the title?
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 |
The LIKE operator allows us to search for patterns in text. Instead of filtering by an exact match (=), we can use wildcard characters:
| Wildcard | Description |
|---|---|
% | Represents zero or more characters |
_ | Represents a single character |
SELECT column1, column2
FROM table_name
WHERE column_name LIKE 'pattern';SELECT title, genre, rating
FROM netflix_series
WHERE title LIKE '%Dark%';| title | genre | rating |
|---|---|---|
| Dark | Sci-Fi | 8.8 |
What’s Happening?
LIKE %Dark% searches for any title that contains the word “Dark” anywhere.% wildcard allows matches at the beginning, middle, or end of the title.| Pattern | Matches | Example Query |
|---|---|---|
D% | Titles that start with “D” | WHERE title LIKE D% |
%Game | Titles that end with “Game” | WHERE title LIKE %Game |
%Mirror% | Titles that contain “Mirror” anywhere | WHERE title LIKE %Mirror% |
S____ Game | Titles that start with “S” and are 11 characters long | WHERE title LIKE S____ Game |
SELECT title, genre
FROM netflix_series
WHERE title LIKE 'S%';| title | genre |
|---|---|
| Stranger Things | Sci-Fi |
| Squid Game | Thriller |
What’s Happening?
LIKE S% ensures that only titles starting with “S” appear in the results.Netflix executives want a list of all series that contain “Game” anywhere in the title.
Filter condition:
title must contain the word “Game”.Expected Output Example:
| title | genre | rating |
|---|---|---|
| Squid Game | Thriller | 8.0 |
Write an SQL query to return the requested data.
Alex is preparing a new recommendation system and wants to identify all Netflix series whose titles start with “B”. Order the table in the ascending order of rating.
Filter condition:
title must start with the letter “B”.Expected Output Example:
| title | genre | rating |
|---|---|---|
| Bridgerton | Drama | 7.3 |
| Black Mirror | Sci-Fi | 8.8 |
| Breaking Bad | Crime | 9.5 |
Write an SQL query to return the requested data.