Analytical Ranking Functions
SQL Server supports four analytical ranking functions: ROW_NUMBER, RANK, DENSE_RANK, and NTILE. These functions provide a simple and highly efficient way to produce ranking calculations. I will also demonstrate alternative solutions to producing ranking values without the built-in ranking functions. Of course, you can feel free to skip the coverage of the alternative solutions, but I’d recommend spending the time to learn those for several reasons. A lot of existing legacy code out there in production systems makes use of those techniques. Also, some of those techniques are quite convoluted, and some have poor performance, so by being familiar with them you gain a greater appreciation for the simplicity and efficiency ...
Get Inside Microsoft® SQL Server® 2008: T-SQL Querying 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.