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

Home -> Community -> Usenet -> c.d.o.tools -> Re: SQL - SELECT x rows...

Re: SQL - SELECT x rows...

From: Zbigniew Sliwa <zibi_at_at_hotmail.com>
Date: 2000/08/10
Message-ID: <yfvk5.10575$FO3.267682@news.tpnet.pl>#1/1

Hi,

Try this:

SELECT a.*

FROM      emp a
WHERE     20 >=
          (SELECT   COUNT(*)
          FROM      emp b
          WHERE     b.age >= a.age)

ORDER BY a.age DESC

Good luck!



Regards,

Zbigniew Sliwa
Oracle Programmer
Poland

email: zibi_at_at_yahoo.com
R.Schulenberg napisa³(a) w wiadomoœci: <8ms6uv$74i$18$1_at_news.t-online.com>...
>Try it with .....where rownum <21 or <101
> - but this will only work when you set 'order by' in a way that the
>required records will be the first ones to be shown -
>
>Rgds Raphaela
>
>"Joseph Ranseth" <jransethNO_SPAM_at_worldcupfishing.com> schrieb im
>Newsbeitrag news:BKgk5.14$Lc.1764_at_news1.mts.net...
>> How can I select 'x' number of rows from/in a query?
>>
>> ie: I want to select the 20 oldest employees, or 100 highest paid, etc.
>>
>> Is there a simple way of going about this, or do I have to select all of
 the
>> records and then only print the desired amount (That wouldn't be
 efficient,
>> though, would it?)
>>
>> Thanks in Advance,
>>
>> JR
>>
>>
>
Received on Thu Aug 10 2000 - 00:00:00 CDT

Original text of this message

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