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

Home -> Community -> Usenet -> c.d.o.misc -> Re: Limit a query

Re: Limit a query

From: Billy Verreynne <vslabs_at_onwe.co.za>
Date: Wed, 14 Aug 2002 13:36:08 +0200
Message-ID: <pan.2002.08.14.13.36.08.139611.11411@onwe.co.za>


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

--
Billy
Received on Wed Aug 14 2002 - 06:36:08 CDT

Original text of this message

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