SQLite PERCENT_RANK() Function
Example
Return the relative rank of each product price:
SELECT ProductName, Price,
PERCENT_RANK() OVER (ORDER BY Price)
FROM Products;
Try it Yourself »
Definition and Usage
The PERCENT_RANK() function returns the relative rank of each row, as a number from 0 to 1. It is calculated as (rank - 1) / (number of rows - 1).
Note: Window functions need an OVER clause. Read more in the SQLite Window Functions chapter.
Tip: Also look at CUME_DIST().
Syntax
PERCENT_RANK() OVER (ORDER BY column)
Technical Details
| Return type: | Real |
|---|---|
| Works in: | SQLite 3.25.0 and later |