User Name Password Register
DaniWeb IT Discussion Community
All
What is DaniWeb IT Discussion Community?
You're currently browsing the MS SQL section within the Web Development category of DaniWeb, a massive community of 427,193 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 2,200 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our MS SQL advertiser: Programming Forums
Views: 1309 | Replies: 7
Reply
Join Date: Dec 2007
Posts: 10
Reputation: rajesh79 is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 0
rajesh79 rajesh79 is offline Offline
Newbie Poster

How to find thrid maximum value from a table

  #1  
Jan 21st, 2008
i have one table.that contains one salary field.I want to find the third maximum row from that field.If anyone knows this please help me

thanks
AddThis Social Bookmark Button
Reply With Quote  
Join Date: Dec 2007
Posts: 287
Reputation: ericstenson is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 28
Colleague
ericstenson's Avatar
ericstenson ericstenson is offline Offline
Posting Whiz in Training

Re: How to find thrid maximum value from a table

  #2  
Jan 21st, 2008
select top 3 COLUMNAME from TABLENAME order by COLUMNAME desc

The first row will be your third highest paid person.
--
"Dummy."
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 762
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: How to find thrid maximum value from a table

  #3  
Jan 22nd, 2008
hmmm,
SELECT MIN(column) FROM table WHERE ( SELECT TOP 3 (column) FROM table ORDER BY column desc )
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Dec 2007
Posts: 287
Reputation: ericstenson is an unknown quantity at this point 
Rep Power: 1
Solved Threads: 28
Colleague
ericstenson's Avatar
ericstenson ericstenson is offline Offline
Posting Whiz in Training

Re: How to find thrid maximum value from a table

  #4  
Jan 22nd, 2008
go with the whiz...
--
"Dummy."
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 762
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: How to find thrid maximum value from a table

  #5  
Jan 22nd, 2008
@erictenson:
sorry??
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Join Date: Nov 2007
Location: Bangalore, India
Posts: 3,098
Reputation: nav33n has a spectacular aura about nav33n has a spectacular aura about 
Rep Power: 8
Solved Threads: 240
nav33n's Avatar
nav33n nav33n is offline Offline
Posting Sensei

Re: How to find thrid maximum value from a table

  #6  
Jan 22nd, 2008
Originally Posted by RamyMahrous View Post
@erictenson:
sorry??


RamyMahrous -> Posting Whiz! Thats what he meant, I guess.
Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning.

*PM asking for help will be ignored*
Reply With Quote  
Join Date: Jun 2005
Location: Nothamptonshire
Posts: 27
Reputation: pclfw is an unknown quantity at this point 
Rep Power: 4
Solved Threads: 1
pclfw pclfw is offline Offline
Light Poster

Re: How to find thrid maximum value from a table

  #7  
Jan 25th, 2008
RamyMahrous' solution doesn't work. Use this instead. select min(s.column) from (SELECT TOP 3 (column) FROM table ORDER BY column desc) s
Reply With Quote  
Join Date: Aug 2006
Location: Egypt
Posts: 762
Reputation: RamyMahrous is on a distinguished road 
Rep Power: 4
Solved Threads: 59
Featured Poster
RamyMahrous's Avatar
RamyMahrous RamyMahrous is offline Offline
Master Poster

Re: How to find thrid maximum value from a table

  #8  
Jan 26th, 2008
Yes, yes I am sorry I was wrong thanks, pclfw
B.Sc Computer Science, Helwan University
Microsoft Student Partner
Personal blog http://ramymahrous.blogspot.com/
Arabic technical blog http://fci-h-ar.blogspot.com/
English technical blog http://fci-h.blogspot.com/
Reply With Quote  
Reply

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

DaniWeb MS SQL Marketplace
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)

 

Thread Tools Display Modes

Other Threads in the MS SQL Forum

All times are GMT -4. The time now is 10:15 pm.
Forum system based on vBulletin Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
©2003 - 2008 DaniWeb® LLC