Re: SQL select first 10 or so entries from a table

From: Bricklen Anderson <bricklen_at_shaw.ca>
Date: Mon, 15 Apr 2002 15:45:16 GMT
Message-ID: <3CBAF4B7.5F9070C9_at_shaw.ca>


Barry, I should rephrase what I wrote yesterday morning..." To limit the values to the first x number, try select * from your_table where rownum < 26; gets you the first 25 rows."
should read...
"To limit your return to the first x number of rows FETCHED...", not necessarily in any particular order. My statement was misleading.

;-)

Bricklen Anderson wrote:
>
> To limit the values to the first x number, try select * from your_table
> where rownum < 26; gets you the first 25 rows.
> If you want to be able to select groups of values after that, you can
> use analytic functions:
>
> -http://technet.oracle.com/doc/oracle8i_816/server.816/a76989/functio2.htm#81409
> -http://asktom.oracle.com/pls/ask/f?p=4950:8:690136::NO::F4950_P8_DISPLAYID,F4950_P8_CRITERIA:750625651018,%7Banalytic%7D%20and%20%7Bfunctions%7D
> for windowing your results (which seems to be what you are after) you
> can start here if you like:
> -http://technet.oracle.com/doc/oracle8i_816/server.816/a76989/functio2.htm#81523
>
> If you are using a version below 8.1.6 of Oracle, then as a workaround
> you could also use a microsoft product, like an Access form etc, to
> limit the result sets easily.
>
> Good luck
>
> barry wrote:
> >
> > Hello, imagine I have lots of tables each containing 30-75,000
> > entries.
> >
> > The query
> >
> > SELECT * FROM tablename WHERE something=somethingelse
> >
> > returns on occasions many thousand hits.
> >
> > What sort of SQL construct do you use to say give me the first 5
> > entries.
> > Then what SQL do you use to get the next 5 entries.
> > Then the SQL to get the 5 after that etc, for a table in a general
> > sense. I don't care about the 'order' of the results that come back, I
> > just want to display things in bite size chunks (like a hitset, and if
> > the user doesn't find the result they're after in the client
> > front-end, they hit the "next" button).
> >
> > Again thank you in advance to everyone that thinks about, or posts,
> > solutions to this query.
> > Barry
Received on Mon Apr 15 2002 - 17:45:16 CEST

Original text of this message