In SQL databases, the RANK()
function is a window function that returns the rank of the current row within its partition, with gaps.
By “with gaps” I mean that if there are any ties for a given rank, there will be a gap between that rank value and the next rank value.
If you don’t want such gaps, use the DENSE_RANK()
function instead, as it returns the rank without gaps.