RSS Forums RSS
Please support our MS SQL advertiser: Programming Forums
Views: 598 | Replies: 1 | Thread Tools  Display Modes
Reply
Join Date: Mar 2007
Posts: 52
Reputation: Gaurav arora is an unknown quantity at this point 
Rep Power: 2
Solved Threads: 0
Gaurav arora Gaurav arora is offline Offline
Junior Poster in Training

How to Retrieve nth maximum salary from the salary table

  #1  
Aug 10th, 2008
Hi I m Having a Problem in retrieving records.
I want to get nth maximum value in a column.
I have tried it using top
select top n ColumnName from tablename where(select top n-1 ColumnName from tablename order by columnName desc)


But i m getting all the n records.
Any idea plz
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Apr 2006
Location: East Amherst, NY
Posts: 102
Reputation: cutepinkbunnies is an unknown quantity at this point 
Rep Power: 3
Solved Threads: 6
cutepinkbunnies's Avatar
cutepinkbunnies cutepinkbunnies is offline Offline
Junior Poster

Re: How to Retrieve nth maximum salary from the salary table

  #2  
Aug 11th, 2008
I have a feeling you're going to have to use a cursor to get that kind of result. Read up on them, it should be pretty easy, but keep in mind they are a bit slow if you're using a lot of data.
Reply With Quote  
Reply

Only community members can participate in forum threads. You must register or log in to contribute.



Other Threads in the MS SQL Forum
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes
Forums | Blogs | Tutorials | Code Snippets | Whitepapers | RSS Feeds | Advertising
All times are GMT -4. The time now is 8:01 pm.
Newsletter Archive - Sitemap - Privacy Statement - Acceptable Use Policy - Contact Us
Forum system based on vBulletin Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC