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

Home -> Community -> Usenet -> c.d.o.server -> Re: How to limit the number of rows returned in a select statement

Re: How to limit the number of rows returned in a select statement

From: Paul Sandwell <paul_sandwell_at_sdt.com>
Date: 1997/06/05
Message-ID: <3396D4D6.6637@sdt.com>#1/1

> 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

Original text of this message

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