Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
![]() |
![]() |
Home -> Community -> Usenet -> c.d.o.misc -> Re: Limit a query
On Wed, 14 Aug 2002 12:19:05 +0200, watscheck wrote:
> I want to know if there is a way to limit the actual query, so that
> oracle stops to go on searching for further records.
>
> I know that there is a way to reduce the ResultSet by adding < ROWNUM or
> using setMaxRows (in JDBC) but this wont reduce the work of the dbms.
You can only limit the output with rownum - the complete data set still needs to be processed,
e.g. Return the top 10 cities ito of highest profit
SELECT
*
FROM
( SELECT
city, SUM( profit ) "PROFIT"
FROM foobar
GROUP BY city
ORDER BY profit DESC
)
WHERE rownum < 11
-- BillyReceived on Wed Aug 14 2002 - 06:36:08 CDT
![]() |
![]() |