Click here to Skip to main content
15,879,474 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
How to get the 3rd highest salary in the salary table
It is my salary table...

NAME SALARY
NAME 120
KAILASH 350
MUNA 100
HARI 400

[Edit]Shouting removed[/Edit]
Posted
Updated 4-Mar-13 3:05am
v4

Hi,
Try this one,
SQL
SELECT Name,Salary FROM (
  SELECT
    ROW_NUMBER() OVER (ORDER BY salary DESC) AS RowNumber, Name, Salary
  FROM yourTable
) AS Demo
WHERE RowNumber= 3


I hope this will work.
Thanks :)
 
Share this answer
 
In Mysql you can use limit :
SQL
select * from tablename order by salary desc limit 1, 3
 
Share this answer
 
Comments
kailash panigrahi 11-Feb-13 10:40am    
Thanks for your comment but I want without using limit.
Mehdi Gholam 11-Feb-13 10:54am    
Features are there for you to use them.
SQL
Select * From Employee E1 Where
    (N-1) = (Select Count(Distinct(E2.Salary)) From Employee E2 Where
		E2.Salary > E1.Salary)


Click Here to learn more...
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900