Showing posts with label sql query. Show all posts
Showing posts with label sql query. Show all posts

Monday, 28 April 2014

how to get nth highest and lowest salary in sql server

Ex Code: Lowest case :

select top 1 column as 'salary' from (select distinct top 4 column from  Table order by ID asc) a order by ID desc

Highest Case:

select top 1 column as 'salary' from (select distinct top 4 column from  Table order by ID desc) a order by ID asc