© Kathi Kellenberger, Clayton Groom, and Ed Pollack 2019
K. Kellenberger et al.Expert T-SQL Window Functions in SQL Server 2019https://doi.org/10.1007/978-1-4842-5197-3_2

2. Discovering Ranking Functions

Kathi Kellenberger1 , Clayton Groom2 and Ed Pollack3
(1)
Edwardsville, IL, USA
(2)
Smithton, IL, USA
(3)
Albany, NY, USA
 

The four ranking functions were introduced to T-SQL by Microsoft in 2005. Three of the functions, ROW_NUMBER, RANK, and DENSE_RANK, assign a sequential number to each row in a query’s results. The fourth ranking function, NTILE, divides the rows by assigning a bucket number to each row in the results. The group of low-ranking rows gets an NTILE value of 1 while the highest-ranking group of rows is assigned the top number.

While adding ...

Get Expert T-SQL Window Functions in SQL Server 2019: The Hidden Secret to Fast Analytic and Reporting Queries now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.