Click here to monitor SSC
SQLServerCentral is supported by Redgate
Log in  ::  Register  ::  Not logged in

Get your favorite SSC scripts directly in SSMS with the free SQL Scripts addin. Search for scripts directly from SSMS, and instantly access any saved scripts in your SSC briefcase from the favorites tab.
Download now (direct download link)

Find Nth Max-Min Record - The Efficient Way!

By ashishnaik1,

It is quite often that we need to find Nth (5th or 8th or 10th) maximum or minimum number of record from the record set.
The solution is different in MS SQL than in Oracle because we have RowNum in Oracle.
Some time ago I got the same problem with a massive table of more than 20 Million records and 56 varchar columns and 1 int column.
I tried different solutions (got from the Internet!) but was disappointed with the performance.
Then I decided to spoil my hands and came up with this solution that is most efficient solution for this problem.

Total article views: 1006 | Views in the last 30 days: 5
Related Articles

Creating Power Map Reporting Solutions Recording and Q&A

I hope you were able to attend my free webinar on Creating Power Map Reporting Solutions on April 1...


Deleting Duplicate Records

In Datawarehousing, a normal scenario is eleminating duplicate records/rows or deleting duplicate re...


SQL Server High Avilabilty Solutions

SQL Server High Avilabilty Solutions


DR solution..Pls respond

DR solution

data warehousing