Articles → SQL SERVER → Rank() Function In SQL Server
Rank() Function In SQL Server
Purpose
Syntax
RANK() OVER ( [PARTITION BY <column(s)>] ORDER BY <expression(s)> )
Example
SELECT
order_id,
product_id,
quantity, price,
RANK() OVER (ORDER BY quantity DESC) AS SalaryRank
FROM orders;
Output