PERCENT_RANK()
PERCENT_RANK calculates the relative rank of a row within a group of rows in the SQL Server Database Engine.
Signature
PERCENT_RANK( )
OVER ( [ partition_by_clause ] order_by_clause )Examples
SELECT product, amount, PERCENT_RANK() OVER (ORDER BY amount) AS pr FROM dbo.orders;product amount pr
---------------------------------------- ------------ ------------------------
cable 15.00 0.0
mouse 27.75 0.20000000000000001
keyboard 49.50 0.40000000000000002
keyboard 99.00 0.59999999999999998
monitor 219.00 0.80000000000000004
monitor 438.00 1.0Run against SQL Server 16.0.4265.3 on 2026-09-13. This is the output we got, not the documentation’s.
Available on
- SQL Server 2017 and later
- Azure SQL Database
- Azure SQL Managed Instance
- Azure Synapse Analytics
- Microsoft Fabric warehouse
- Fabric SQL database
Signature and description adapted from the Microsoft SQL documentation, used under the CC BY 4.0. SQL Server and Azure are trademarks of the Microsoft group of companies. This page is not affiliated with Microsoft.