I want to know if there is a way to select a subsequent bunch of rows in select query in Ingres. For example, the first 500 rows can be selected by using the select first 500 from tablename, but if I want to select rows 501 to 1000, is there any way to do that?
A:
You can use the OFFSET clause in the following way:
SELECT col_name
FROM table
WHERE col_name = 'value'
OFFSET m FETCH FIRST n ROWS ONLY
For example
SELECT *
FROM table
OFFSET 501 FETCH FIRST 500 ROWS ONLY
grantc
2009-07-04 09:17:06
A:
Thanks grant, What i gather from the ingres.com site is that the 'OFFSET' has been introduced only in Ingres9.2 .My client currently uses Ingres2006 so it does not support the 'OFFSET' tag. Is there another way around?
Regards, Rashmi
Rashmi
2009-07-06 08:49:45
Unfortunately not
grantc
2009-07-21 10:07:29
A:
You can use
SELECT FIRST 10 * FROM table or SELECT FIRST 10 field1, field2 FROM table
I tested it in Ingres 9.2 and it works
See also: http://stackoverflow.com/questions/49602/how-to-limit-result-set-size-for-arbitrary-query-in-ingres
Adrian
2009-10-12 09:12:10
Thanks Adrian. we are upgrading to Ingres9.2 next year so i will be able to to amke it work then.
Rashmi
2009-10-12 11:36:31
A:
you can try restricting the row number using the "rownum" var:
SELECT * from TABLE
WHERE rownum <=500
i haven't tested it on your problem, but it should work fine :
SELECT * from TABLE
WHERE rownum >500
AND rownum <= 1000
gion_13
2010-01-19 14:51:33
Ingres does not have a rownum column. There is a hidden tid column however the value contained is based on the page number and it's position within the page.
grantc
2010-02-22 10:32:01