Monday, January 30, 2012

Query to find nth hieghst salry in sql

Declare @sal int
Set @sal=1    --------(what ever position you want)
Select E1.Esalary from MyEmployee E1
Where @sal=(select Count(distinct E2.Esalary) from MyEmployee E2
Where E2.Esalary >= E1.Esalary)
Go

No comments:

Post a Comment