Powered by Blogger.

Saturday, February 15, 2014

Get nth highest lowest salary in SQL Server 2008




In this post we will discuss how to get nth highest lowest salary in SQL Server 2008. In this post we will discuss about:

- List all Stored Procedure Created and Modified in Last N Days in SQL Server 2008

- Difference between primary key and foreign key in SQL server

- Method Overloading in C#.Net

Nth Highest salary:

Below is the query to get 5th highest salary from Salary table in Sql Server 2008:

Select TOP 1 Salary as '5th Highest Salary'
from (SELECT DISTINCT TOP 5 Salary from EmpSalary ORDER BY Salary DESC)
temptbl ORDER BY Salary ASC

Nth Lowest salary:

Below is the query to get 5th highest salary from Salary table in Sql Server 2008:

Select TOP 1 Salary as '5th Lowest Salary'
from (SELECT DISTINCT TOP 5 Salary from EmpSalary ORDER BY Salary ASC)
temptbl ORDER BY Salary DESC  



0 comments

Post a Comment