PDA

View Full Version : How to suppress exceeding number of records


H303
02-25-03, 14:30
Is there any way how to limit the number of returned records to a certain value? I have a table which holds millions of measurement data and timestamps. When I do a select for a certain time range, I may get back thousends of records and I only need to present the first 25 for a preview.
The function COUNT(*) will not work, since I cannot calculat something like ... select where ... COUNT(*) > (COUNT(*) -25)
Many thanks for every hint!
Hermann

stevetucknott
02-26-03, 04:05
Within Informix there is a directive that you can give that will limit the rows returned (Not sure which release this appeared in though, so you'll have to check your documentation).... the syntax is:

SELECT FIRST n column_name FROM table_name

eg

SELECT FIRST 10 * FROM systables

OR

SELECT FIRST 3 tabid,tabname FROM systables

thebap
02-27-03, 08:11
MySQL - also uses the LIMIT keyword

For Oracle - SELECT * FROM TABLE_XXX WHERE ROWNUM < 100;