Forum

How to display all ...
 
Share:
Notifications
Clear all

How to display all the details of employee who is getting 3rd highest salary in employee table.


kumar BI
Posts: 18
 kumar BI
Topic starter
(@kumar BI)
Joined: 2 years ago

Display all the details of employee who is getting 3rd highest salary in employee table.

3 Replies
B Naresh
Posts: 47
 B Naresh
(@B Naresh)
Joined: 2 years ago
To display all the details of employee who is getting 3rd highest salary in employee table. We can write something like, 
 
With EmpCTE As
(
Select *,  Dense_Rank() Over(Order By Salary Desc) As DNS_RNK
From Employee
Where 
Select * from EmpCTE Where DNS_RNK=3
 
You may try this and let me know.
 
Reply



Vikky
Posts: 15
 Vikky
(@Vikky)
Joined: 2 years ago

There are many ways to do achieve the 3rd highest salary in the employee table.

Here my inner query will return the second highest salary and again from the results we have ignored the max of salary which means it is going to be the third-highest salary.

Hope you may try this one. 

With Results As

(

Select * from employee

where

Salary Not IN (Select Max(Salary) From Employee group by deptid;

)

Select * from Results Where Salary Not In ( Select Max(Salary) from Results;

Try this and tell me. 

Reply
Vikky
Posts: 15
 Vikky
(@Vikky)
Joined: 2 years ago

Group by was missing at the end try this one. 

With Results As

(

Select * from employee

where

Salary Not IN (Select Max(Salary) From Employee group by deptid;

)

Select * from Results Where Salary Not In ( Select Max(Salary) from Results group by deptid)

Reply



Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: