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

From: Bricklen Anderson <bricklen_at_shaw.ca>
Date: Sun, 14 Apr 2002 15:23:41 GMT
Message-ID: <3CB99E29.2A8E72EB_at_shaw.ca>


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 Sun Apr 14 2002 - 17:23:41 CEST

Original text of this message