DENSE_RANK
A window function that gives tied rows the same position without leaving gaps, as in 1, 2, 2, 3.
In more detail
RANK tells you how many rows are ahead of this one, while DENSE_RANK tells you how many different values are ahead. Choose between them deliberately whenever ties are possible.
Related terms
- RANK — A window function that gives tied rows the same position and then skips positions, as in 1, 2, 2, 4.
- ROW_NUMBER — A window function that numbers rows 1, 2, 3 in the window's order, giving tied rows different numbers.
- window function — A calculation across a set of rows related to the current row that, unlike GROUP BY, keeps every input row in the answer.
Taught in
- Advanced Window Functions: Ranking And Framing — PostgreSQL, Indexing & Relational Data Modeling