RANK
Assigns places with ties: equal values share a place, and the next one is skipped.
Syntax
RANK() OVER (ORDER BY <sort key>)
RANK() OVER (PARTITION BY <group> ORDER BY <sort key>)
Just like in a competition: two people with the same result share second place, and the next one comes fourth, because third is already “taken”. A window function: the number of rows stays the same, and each gets its own place. PARTITION BY ranks separately within each group.