I have previously written SQL SERVER – 2005 – Find Nth Highest Record from Database Table where I have shown query to find 4th highest record from database table. Everytime when I write blog I am always very eager to read comments of readers. Some of regular readers are industry leaders and and their comments always teach us all something new. One of them is Nicholas Paldino [.NET/C# MVP]. He has always provided valuable solution and comments to this blog. His recent comment about finding Nth Highest Record is quite an interesting.

USE AdventureWorks GO SELECT t.* FROM ( SELECT e1.*, row_number() OVER ( ORDER BY e1.Rate DESC) AS _Rank FROM HumanResources.EmployeePayHistory AS e1 ) AS t WHERE t._Rank = 4
Want to try this yourself? Here is how to install AdventureWorks.
Published by Pinal Dave on SQLAuthority. More of my work at pinaldave.com.
Discover more from SQL Authority with Pinal Dave
Subscribe to get the latest posts sent to your email.





24 Comments. Leave new
Thanks Sir .