15,882,114 members
1.00/5 (1 vote)
See more:
I want to get third maximum salary....
For that the given below query is working...
If we have more than one same salary(45000) means it will display last inserted value only.... I need to display all the 3rd maximum salary

SQL
```CREATE TABLE Employee([Eid] [int] NULL,[Ename] [nvarchar](255) NULL,[Basic_Sal] [float] NULL)

insert into Employee values(1,'Neeraj',45000)
insert into Employee values(2,'Ankit',5000)
insert into Employee values(3,'Akshay',6000)
insert into Employee values(4,'Ramesh',7600)
insert into Employee values(5,'Vikas',4000)
insert into Employee values(7,'Neha',8500)
insert into Employee values(8,'Shivika',4500)
insert into Employee values(9,'Tarun',9500)
insert into Employee values(10,'meera',45000)
insert into Employee values(11,'kajal',45000)
insert into Employee values(12,'hansika',45000)

select Ename,Basic_sal
from(select Ename,Basic_Sal,ROW_NUMBER() over (order by Basic_Sal desc) as rowid from Employee)A
where rowid=3```

Posted

## Solution 1

Hi,

Use following query :

SQL
```select Ename,Basic_sal, [rank]
from(select Ename,Basic_Sal,DENSE_RANK() over (order by Basic_Sal desc) as [rank] from Employee)A
where [rank]=3```

Thanks,
Bhagyesh