Alright. We'll start with the most widely used ranking function:
RANK(). The syntax is as follows:
RANK() OVER (ORDER BY ...)
RANK() do? It returns the rank (a number) of each row with respect to the sorting specified within parentheses.
ORDER BY sorts rows and shows them in a specific order to you.
RANK() OVER(ORDER BY ...) is a function that shows the rank(place, position) of each row in a separate column.
Let's look at an example from our database:
RANK() OVER(ORDER BY editor_rating)
The first three columns are quite obvious, but look what happens next: we want to return the rank (
RANK()) of each row when we sort them by the column
OVER(ORDER BY editor_rating).