Path: dp-news.maxwell.syr.edu!spool.maxwell.syr.edu!drn.maxwell.syr.edu!news.maxwell.syr.edu!newsfeed.icl.net!newsfeed.fjserv.net!feed.news.tiscali.de!fu-berlin.de!uni-berlin.de!individual.net!not-for-mail
From: "Robert Klemme" <bob.news@gmx.net>
Newsgroups: comp.databases.oracle.misc
Subject: Re: selecting top performers
Date: Mon, 8 Aug 2005 15:49:23 +0200
Lines: 28
Message-ID: <3lp676F13oli6U1@individual.net>
References: <1123500018.839903.68240@g14g2000cwa.googlegroups.com> <42F75B8C.4030509@gmail.com>
Mime-Version: 1.0
Content-Type: text/plain;
 charset="iso-8859-1"
Content-Transfer-Encoding: 7bit
X-Trace: individual.net FQw5rYSs75svo9puNaepoAWthmJQBk/Q8780m7bsDfgxVgJDo=
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2800.1506
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1506
Xref: dp-news.maxwell.syr.edu comp.databases.oracle.misc:121105

amogh wrote:
> baroo wrote:
>> Hi
>>
>> How do I select the top 20 earners from my database?
>>
>> urgent.
>>
>> cheers
>>
> The simplest top(n) query you can write:
>
> SELECT a.earnings FROM
> (SELECT earnings FROM
>   YOUR_TAB
>   ORDER BY earnings DESC
> )a
> WHERE ROWNUM < 21
>
>
> Regards,
> Amogh

If I'm not mistaken you can even omit the query nesting and use the ROWNUM
filter on the inner query directly.

    robert

