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.


Posts: 18
Guest
Topic starter
(@kumar BI)
Active Member
Joined: 3 years ago

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

3 Replies
Posts: 47
Guest
(@B Naresh)
Eminent Member
Joined: 3 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

Self Learning Video Tutorials - Software Course

Posts: 32
Guest
(@Vikky)
Eminent Member
Joined: 3 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
Posts: 32
Guest
(@Vikky)
Eminent Member
Joined: 3 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

Self Learning Video Tutorials - Software Course

Leave a reply

Author Name

Author Email

Title *

 
Preview 0 Revisions Saved
Share: