Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.server -> Re: Sql Query

Re: Sql Query

From: Lothar Armbrüster <la_at_oktagramm.de>
Date: Fri, 24 Nov 2000 17:42:12 +0100
Message-ID: <PM000376D57753A40D@hades.unknown.dom>

Paul wrote:
> I,m new to sql and wonder if anybody could help me with the following:
> If I had a table with say order id and order total i.e
>
> id total
> 213 567.35
> 345 444.00
> 214 32.99
> and so on how would I find say just the fourth highest total from the
> table without displaying the rest of the table.
> Thanks for any help.

If you have a sufficiently new version of Oracle (I think 8.1.5 or higher) you could do the following:

select id,total from

   (select id,total,rownum r from

       (select id,total from table_name
        order by total desc))

where r=4;

I hope this works. At the moment I don't have my Oracle available to test.

Hope that helps,
Lothar

-- 
Lothar Armbrüster       | la_at_oktagramm.de
Hauptstr. 26            | la_at_heptagramm.de
D-65346 Eltville        | lothar.armbruester_at_t-online.de
Received on Fri Nov 24 2000 - 10:42:12 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US