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

SQL Practice: Filtering and Sorting a Movie Catalog

Same skills, new shelves: put SELECT, WHERE, and ORDER BY to work on a movie catalog.

You have spent ten chapters in the Garden Shop. This chapter hands you a brand-new dataset: a small Movie Rentals shop, so you can prove the skills transfer to data you have never seen. Nothing new to learn here: just the same tools on a fresh problem.

The movies table has one row per film, with a genre, a release_year, and a numeric rating. That is everything a top-rated list needs.

Filter first, then sort

A ranked shortlist is two steps: keep the rows you care about with WHERE, then arrange them with ORDER BY. When several rows share the top value, add a second sort column so the order is stable every time the query runs.

Pattern
select columns
from table_name
where condition
order by sort_column desc, tie_breaker
Schema · Movie RentalsTable · movies5 columns · 12 rows
Table · movies

One row per movie in the catalog.

5 columns · 12 rows
movie_id inttitle textgenre textrelease_year intrating decimal
Your task

From movies, return the title, genre, release year, and rating for every film rated 8.0 or higher, highest rating first. Break ties by title.

SQL Workbench
query.sqlmovie_rentals · SQL engine loading
⌘↵ to run
·
Expected answer
  • Columns: title, genre, release_year, rating.
  • Rows: 4 movies rated 8.0 or higher.
  • The first row should be Paper Lanterns at 8.7.