SQLite DENSE_RANK() Function
Example
Rank the products by price, without gaps:
SELECT ProductName, Price,
DENSE_RANK() OVER (ORDER BY Price DESC)
AS DenseRnk
FROM Products;
Try it Yourself »
Definition and Usage
The DENSE_RANK() function gives each row a rank. Rows with the same value get the same rank, and the next rank does not skip numbers. For example: 1, 2, 2, 3.
Note: Window functions need an OVER clause. Read more in the SQLite Window Functions chapter.
Tip: Also look at RANK().
Syntax
DENSE_RANK() OVER (PARTITION BY column ORDER BY column)
Technical Details
| Return type: | Integer |
|---|---|
| Works in: | SQLite 3.25.0 and later |