Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: Selects only the first 200 records aftering ordering from a table.
Try this
select A from your_table
where A in ( select A from your_table group by A)
and rownum < 501;
Colin Woods <newsgroupcw_at_hotmail.com> wrote in article
<3535FC1F.1FE9_at_hotmail.com>...
> Folks,
>
> Can anyone help me ?
>
> I have a large table, where I only want to select up to a maximum of 500
> records.
>
> I can't use ROWNUM because I want to perform an ORDER BY on the table
> before taking out the first 500 records.
>
> The statement I has was
>
> SELECT A, B, C
> FROM table
> WHERE Condition
> AND rownum < 500
> ORDER BY C, B
>
> What this select does is select 500 records, and then orders them.
>
> What I want is to order all records first, and then return the first
> 500(after ordering).
>
> Anyoue any ideas ?
>
> P.S. I don't want to use PL/SQL and a CURSOR select if possible !.
>
> THANKS
>
> Colin Woods.
>
Received on Sun Apr 19 1998 - 09:47:13 CDT