.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Forum >> Sql Server >> Post New QuestionBookmark and Share Subscribe to Forum

How to find the fifth highest salary in a table without using top query?

Posted By: Ramesh P     Posted Date: October 30, 2010    Points:2   Category :Sql Server
How to find the fifth highest salary in a table without using top query?

Responses
Author: Syed Shakeer Hussain             
Posted Date: October 30, 2010     Points: 5   

Hi Ramesh,

Run the Below Query to get 5th highest Salary.

with CTE as(select dense_rank() over( order by salary desc) row,salary from tableName)
select * from CTE where row=5


Author: Dhivakaran             
Posted Date: October 31, 2010     Points: 5   

Hi Ramesh,
you can use below query for find fifth maxmum salary.
Select salary from emp a where 4=(select count(distinct(b.salary)) from emp b where b.salary>a.salary)

-
Dhivakaran T
Author: Ramesh P             
Posted Date: October 31, 2010     Points: 5   

hi Syed,

Should i use dense_rank() function or rank () function()?

Regards,
Ramesh.

Regards,


Ramesh



Post Reply

You must Sign In To post reply
 
 
Find more Forum Questions on C#, ASP.Net, Vb.Net, SQL Server and more Here
Quick Links For Forum Categories:
ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  OOPs  SilverlightIISJQuery
JavaScript/VBScriptBiztalkWPFPatten/PracticesWCFOthers
www.DotNetSpark.comUnAnsweredAll

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend