fourth highest salary in a table [Resolved]

Posted by Krishnamanohar under Sql Server on 4/22/2013 | Points: 10 | Views : 808 | Status : [Member] | Replies : 3
Hi experts,
what is best way of getting the fourth highest salary of an employee if two employees having same fourth highest salary?not using dense rank and top?
Thanks in Advance
Krish




Responses

Posted by: Kirthiga on: 4/24/2013 [Member] Starter | Points: 50

Up
0
Down

Resolved
Hi Krishnamanohar,

I think Dense_Rank is the best and simple way for getting the highest salary

Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Satyapriyanayak on: 4/22/2013 [Member] [MVP] Silver | Points: 25

Up
0
Down
select distinct(salary) from employee A where 4=(select count(distinct(salary)) from employee B where A.salary<=B.salary)

If this post helps you mark it as answer
Thanks

Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Jayakumars on: 4/23/2013 [Member] [MVP] Bronze | Points: 25

Up
0
Down
hi

try this Query
Select *,Row_Number() over (order by Salary Desc)as Id from Tbl_Salary where Id=4

Mark as Answer if its helpful to you

Krishnamanohar, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response