SQL Flow Field Guide

RANK

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

ranking

What changes

Input
partition and ORDER BY columns of OVER
Output or change
one rank or number per row
Return type
bigint

Syntax at a glance

RANK ( ) OVER ( [ partition_by_clause ] order_by_clause )

Work example

Rank scores while giving tied values the same position.

Create a tie and compare RANK with DENSE_RANK on the same ordered rows.

Check your work RANK leaves gaps after ties, so positions can jump.

Practice SQL

Open in SQL Flow
SELECT score, RANK() OVER (ORDER BY score DESC) AS place FROM (VALUES (90), (90), (80)) AS v(score);

Open Microsoft Learn for full syntax, permissions, and details for your version.