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: Select First 500 Rows of a Table

Re: Select First 500 Rows of a Table

From: Rene Nyffenegger <rene.nyffenegger_at_gmx.ch>
Date: 18 Aug 2004 10:00:33 GMT
Message-ID: <slrnci6a5l.37g.rene.nyffenegger@zhnt60m34.netarchitects.com>


In article <91721cf.0408171304.50618189_at_posting.google.com>, Michael wrote:
> Hello,
>
> In Oracle 8.17 from SQLPLus how can I SELECT the first 500 rows of a
> table? I am versed in creating (filtering out) data using a WHERE
> clause - this is different than that.
>
> I ideally would like to SELECT the first 500 records of a table then
> the NEXT 500 and so forth.
>
> Thanks for your advice,
>
> Michael

First, first rows is a bit vague. There needs to be a sorting criteria.

Something like this should work:

select
  x, y, z
from (
  select x,y,z, ROWNUM r
  from my precious_table
)
where r between 1 and 500;

See also http://www.adp-gmbh.ch/ora/sql/examples/first_rows.html

hth,
Rene

-- 
  Rene Nyffenegger
  http://www.adp-gmbh.ch/
Received on Wed Aug 18 2004 - 05:00:33 CDT

Original text of this message

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