Re: how can i find out the second maximum value from a table by sql

From: Bricklen Anderson <bricklen13_at_hotmail.com>
Date: 14 Feb 2002 09:31:49 -0800
Message-ID: <b416ca2d.0202140931.37e4dc6f_at_posting.google.com>


Oops, I totally missed that reference to the SECOND highest value.

depends on what you are trying to find:
select max(number_value)-1 from your_table; (if they are incremental numbers). or:
Try an analytic function like rank etc:

select your_column
from (select your_column

      rank() over
      (order by your_column desc) rank_val
      from your_table)

where rank_val = 2;

bricklen13_at_hotmail.com (Bricklen Anderson) wrote in message news:<b416ca2d.0202140738.18b38bf_at_posting.google.com>...
> simply enough:
>
> select max(column_containing_the_value) from your_table_name;
>
> sohelcsc_at_yahoo.com (Leader) wrote in message news:<b1a93c73.0202132336.4191d0e6_at_posting.google.com>...
> > Hi all,
> > How can i find out the second maximum value from a table by sql.
> >
> >
> > thanks
> > Hoque
Received on Thu Feb 14 2002 - 18:31:49 CET

Original text of this message