Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.misc -> Re: selecting top performers
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 Received on Mon Aug 08 2005 - 08:49:23 CDT