Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How to limit the number of rows returned in a select statement
> Paul Sandwell wrote:
> <snip>
>> If you want to see only a few rows because that gives whatever info you
>> need and the query execution itself is not a matter of concern, then use
>> your original SELECT statement as a subselect of an outer SELECT which
>> limits on ROWNUM. Like this:
>>
>> SELECT * from (select X,Y from table_a order by Y) where rownum < 10;
>>
> <snip>
>
> Paul,
> I don't THINK you can use an order by clause in a subselect, so the
> above won't work. I could be wrong, however.
> ---
Thanks for the check there, Alan, you are indeed correct. But you can use a GROUP BY function in the subselect which, in simple cases such as selecting a single column from one table, has the same effect. I'll check it out next time before shooting off my mouth!
Paul Received on Thu Jun 05 1997 - 00:00:00 CDT