View previous topic :: View next topic
|
Author |
Message |
krishna_mf
New User
Joined: 31 Jan 2007 Posts: 56 Location: banglore
|
|
|
|
hi,
can any one please tell me how to get third largest element in a table |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Set up a cursor to SELECT, ORDER BY DESC, and then use the 3rd result fetched. |
|
Back to top |
|
|
Craq Giegerich
Senior Member
Joined: 19 May 2007 Posts: 1512 Location: Virginia, USA
|
|
|
|
krishna_mf wrote: |
hi,
can any one please tell me how to get third largest element in a table |
Code: |
SELECT MAX(ELEMENT) FROM TABLE
WHERE ELEMENT < (SELECT MAX(ELEMENT) FROM TABLE)
|
That will get you the second largest element, you should be able to expand that to get the third largest. |
|
Back to top |
|
|
skkp2006
New User
Joined: 14 Jul 2006 Posts: 93 Location: Chennai,India
|
|
|
|
Try this out......
Select * From Table A Where
(N-1) = (Select Count(Distinct(B.Empid)) From Table B Where
B.Empid > A.Empid)
Regards
Syam |
|
Back to top |
|
|
|