Introduction
Simple OVER()
PARTITION BY
11. PARTITION BY – Revision
Ranking functions
Window frame
Analytic functions
ORDER BY PARTITION BY
Order of evaluation
Summary

Instruction

Perfect! Let's continue our adventure. In Part 3, we introduced PARTITION BY, which we used to show window functions for groups of rows rather than all rows in the query result. Take a look:

SELECT
  first_name,
  last_name,
  country,
  COUNT(id) OVER(PARTITION BY country)
FROM customer;

The above query shows the data about each customer along with the count of customers from the same country.

Exercise

For each movie, show its title, editor_rating, genre and the average editor_rating of all movies of the same genre.

Stuck? Here's a hint!

You will need to partition by the genre.

Console

Code editor

Result

TableConsole