Skip to content
/Chapter 11 · Applied Practice: Movie Rentals
Lesson 11.5·movie_rentals
Lesson 11.5

SQL IS NULL Practice: Finding Unreturned Rentals

Missing data is a signal: an empty returned_date means the movie is still on loan.

In rentals, a returned movie has a returned_date. A movie still on loan has none, so the value is NULL. Finding those rows is how a shop knows what is still out on the shelves.

NULL means "unknown", so it never equals anything, not even another NULL. That is why returned_date = NULL silently matches zero rows.

Use IS NULL, not = NULL

Test for missing values with IS NULL (and its partner IS NOT NULL). This is one of the most common beginner mistakes, and it fails quietly: no error, just an empty result. Joining to customers and movies turns the raw ids into a report someone can act on.

Pattern
select columns
from table_name
where nullable_column is null
Schema · Movie RentalsTable · rentals6 columns · 26 rows
Table · rentals

One row per rental. Movies still out have a null returned_date.

6 columns · 26 rows
rental_id intcustomer_id intmovie_id intrental_date datereturned_date dateamount decimal
Your task

List every rental that has not been returned. Return the customer's first and last name, the movie title, and the rental date, oldest first.

SQL Workbench
query.sqlmovie_rentals · SQL engine loading
⌘↵ to run
·
Expected answer
  • Columns: first_name, last_name, title, rental_date.
  • Rows: 6 rentals still checked out.
  • The oldest unreturned rental is Sofia Ramirez with The Last Orchard on 2023-06-05.