Introduction
Simple OVER()
PARTITION BY
Ranking functions
Window Frames
Analytic Functions
PARTITION BY ORDER BY
26. PARTITION BY ORDER BY – Review and Exercise 1
Order of Evaluation
Finished!

Instruction

Remember Part 7, the one we just completed? This is where we learned to combine ORDER BY with PARTITION BY. Here’s a sample query:

SELECT
  Title,
  ReleaseYear,
  LEAD(Title) OVER(PARTITION BY Genre ORDER BY ReleaseYear ASC) AS Lead
FROM Movie;

In the above example, the last column will show the next Movie released in the same Genre.

Exercise

For each movie, show its Title, Genre, EditorRating, and a Rank based on the EditorRating for all movies in the same Genre. The best movies should have the rank of 1.

Stuck? Here's a hint!

You'll need:

PARTITION BY Genre ORDER BY EditorRating DESC