Skip to content

Instantly share code, notes, and snippets.

@florestankorp
Created February 7, 2020 19:43
Show Gist options
  • Save florestankorp/fa10aa941fe9408d0ea4d3a7f5d370b1 to your computer and use it in GitHub Desktop.
Save florestankorp/fa10aa941fe9408d0ea4d3a7f5d370b1 to your computer and use it in GitHub Desktop.
-- Write a SQL query to list the titles of the five highest rated movies
-- (in order) that Chadwick Boseman starred in, starting with the highest rated.
-- Your query should output a table with a single column for the title of each movie.
-- You may assume that there is only one person in the database with the name
-- Chadwick Boseman.
SELECT title, rating
FROM movies
JOIN ratings on movies.id = ratings.movie_id
JOIN stars on movies.id = stars.movie_id
JOIN people on stars.person_id = people.id
WHERE name = "Chadwick Boseman"
ORDER BY rating DESC
LIMIT 5
@Mohamed-Salah-1
Copy link

The query should output a single column table, not two. You can delete rating from the first SELECT

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment