Get nth highest and lowest salary of an employe


Query to get nth(3rd) Highest Salary

 Select TOP 1 Salary as '3rd Highest Salary'
from (SELECT DISTINCT TOP 3 Salary from Employee ORDER BY Salary DESC)
a ORDER BY Salary ASC



Query to get nth(3rd) Lowest Salary


 Select TOP 1 Salary as '3rd Lowest Salary'
from (SELECT DISTINCT TOP 3 Salary from Employee ORDER BY Salary ASC)
a ORDER BY Salary DESC 

0 comments:

Post a Comment

Vikram Chandra Theme by BloggerThemes & NewWPThemes Sponsored by iBlogtoBlog