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: Does Oracle SQL Have TOP Keyword?

Re: Does Oracle SQL Have TOP Keyword?

From: MyNudeHaircut <mynudehaircut_at_aol.com>
Date: 2000/05/27
Message-ID: <20000527101550.18355.00000376@ng-ca1.aol.com>#1/1

Dianne,
I'm just learning Oracle myself, so there may be a better way to do this, but here is one way:

There is a pseudo column named ROWNUM that is not stored in the database but is available for every record retrieved from the database. The ROWNUM column changes every time a query is executed and is assigned to the result records one by one sequentially. Therefore the ROWNUM for the first record received is 1, the second record is 2, etc. This can be used to limit the resultset, like so:

SELECT ROWNUM, customer_name
FROM s_customer
WHERE ROWNUM < 6;

Because ROWNUM is assigned upon retrieval, it is assigned prior to any sorting.  Therefor the particular ROWNUM will not necessarily correspond to the sorting order.

No great Oracle knowledge here, this is from my Oracle PL/SQL book. Hope it helps. Received on Sat May 27 2000 - 00:00:00 CDT

Original text of this message

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