declare @N int set @N = 5 Select * From Employee E1 Where (@N-1) = (Select Count(Distinct(E2.Salary)) From Employee E2 Where E2.Salary > E1.Salary)
Source: https://weblogs.sqlteam.com/mladenp/2005/08/01/7421/Viewed 17177 times