Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: First 20 records from a select, after ordering
In article <7vdhmg$mr4$1_at_nnrp1.deja.com>,
Billy Collins <billy_collins_at_my-deja.com> wrote:
> Hi,
>
> Is there a way for me to retrieve only the first 20 rows from oracle
> AFTER doing an ORDER BY?
>
> The rownum is executed while the SELECT is executing, as discussed in
a
> recent thread, and this gets distorted after sorting is done. I wish
to
> retrieve only the first 20 records after this sorting..
>
> SELECT FIRST 20 <column_name> FROM <tablename> ORDER BY <column_name>
>
> Something like this possible?
>
> I am using Oracle 8.
>
> Thanks!
>
> Good day
> Billy
This is one clear case for PL/SQL. Define a cursor to do the select with the ORDER BY and fetch just the first 20 rows.
(Right tool for the job again).
--
Ed Prochak
Magic Interface, Ltd.
ORACLE Development, conversions, training and support
440-498-3700 magic_at_interfacefamily.com
Sent via Deja.com http://www.deja.com/
Before you buy.
Received on Sat Oct 30 1999 - 00:07:31 CDT
![]() |
![]() |