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

Home -> Community -> Mailing Lists -> Oracle-L -> Re: SQL Q: Ten highest rows

Re: SQL Q: Ten highest rows

From: Yosi Greenfield <yosi_at_comhill.com>
Date: Mon, 19 Jun 2000 15:42:23 -0400
Message-Id: <10533.109766@fatcity.com>


In Oracle 8i and up you can put order by in a subquery. Works great.

HTH. Djordje Jankovic wrote:

> Friends,
>
> A SQL question (not PL/SQL - I know how to do it in PL/SQL, but it is pretty
> clumsy).
>
> Can you select e.g. ten rows with the highest value of a certain column ?
>
> It is not allowed to put "order by" in a subquery, e.g. :
>
> select val
> from (select val from tab order by val)
> where rownum < 11),
>
> and rownum is applied before the group by, (e.g.:
>
> select val
> from tab
> where rownum < 11
> order by val
>
> Thanks a lot.
>
> Djordje
> --
> Author: Djordje Jankovic
> INET: djankovic_at_corp.attcanada.ca
>
> Fat City Network Services -- (858) 538-5051 FAX: (858) 538-5051
> San Diego, California -- Public Internet access / Mailing Lists
> --------------------------------------------------------------------
> To REMOVE yourself from this mailing list, send an E-Mail message
> to: ListGuru_at_fatcity.com (note EXACT spelling of 'ListGuru') and in
> the message BODY, include a line containing: UNSUB ORACLE-L
> (or the name of mailing list you want to be removed from). You may
> also send the HELP command for other information (like subscribing).
Received on Mon Jun 19 2000 - 14:42:23 CDT

Original text of this message

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