rss

Sep
01

Retrieving nth Salary from DB

Posted (Amit) in General on 01-09-2009

1

This query lets you find the nth highest salaries employees.

Select * From @Table [T1] Where
(2 = (Select Count(Distinct [ESalary]) From @Table [T2] where [T1]।[ESalary] <= [T2].[ESalary]))

Replace 2 with 3,4 ,5,6 etc to get the 3,4 ,5,6 etc highest salaried employees

Share

Comments (1)

[...] This post was Twitted by amityadav [...]

Post a comment



Amit Yadav is Stephen Fry proof thanks to caching by WP Super Cache