Congratulations to all the winners of April 2013, they have won INR 3400 cash and INR 20147 worth prizes !
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 15861 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > SQL Server > How to find the Nth Highest Salary in the Table? ...
Sourabh07

How to find the Nth Highest Salary in the Table?

 Code Snippet posted by: Sourabh07 | Posted on: 10/23/2012 | Category: SQL Server Codes | Views: 361 | Status: [Member] | Points: 40 | Alert Moderator   


In the followin query:

'N' represents Nth Highest Salary eg: 1st Highest Salary, 2nd Highest Salary etc.

Query:


Select top(1) *
From Table_Name
Where Pk_ID_Column in
(
Select top(N) Pk_ID_Column
From Table_Name
Order by salary_column desc
)
Order by salary_column


Sourabh07
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/19/2013 1:45:44 PM