TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
C# Corner
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Finding nth highest salary from a table
Nitin
Apr 03, 2015
4.5
k
0
1
facebook
twitter
linkedIn
Reddit
WhatsApp
Email
Bookmark
In this blog we will see how to find the nth highest salary from a given table.
I have a table. Let us have a look at the contents of it.
We will find out the second highest salary from this table. Write the following query in the query analyser.
select
min
(salary)
from
EmpSalary
where
Salary
in
(
select
top
2 Salary
from
EmpSalary
order
by
salary
desc
)
Execute the preceding script.
For finding out the 3rd highest salary just replace 2 by 3 in the sql command.
select
min
(salary)
from
EmpSalary
where
Salary
in
(
select
top
3 Salary
from
EmpSalary
order
by
salary
desc
)
Finding nth highest salary from a table
Next Recommended Reading
Select Top 3 and nth highest department wise salary from employee master using partition By clause