View Single Post
  #8 (permalink)  
Old 07-16-2007, 05:28 AM
Unregistered
 
Posts: n/a
Default ANY answer. Re: How to find second highest value of a column in a table?

Hello can any buddy suggest me how to get the 3rd highest value from table and can ve right any query to get 4th, 5th as well?

For finding 2'nd largest row , we can use various forms ..like
(1)
[sql]select max(value1) from ( select value1 from val minus select max(value1) from val );[/sql]
(2)
[sql]Select max(value1) from val where value1 < ( Select max(value1) from val );[/sql]
(3)
[sql]select max( value1) from val where value1 not in( select max(value1) from val );[/sql]
But there is 1 General way also..we can simply use this formula--
[sql]select rownum,ename,eno from emo gropu by rownum,ename,eno having rownum > n minus select rownum, ename , eno from emp group by rownum,ename,eno having rownum > n ;[/sql]

cheers...
Reply With Quote