AW: "Rownum" in Informix
Posted in 2006
Serge Rielau wrote:
> > Kuldeep wrote:
> >> RowNum in Informix? How to implement it
> >> any syntax,ponters,e.g
...
> >
> ROWNUM in Oracle is used to limit resultsets.
> E.g.
> SELECT * FROM T WHERE rownum < 5>
> So it's a "relative row number" rather than a rowid.
>
The more or less equivalent in Informix is
SELECT FIRST n * from T
But be aware:
In ORACLE:
SELECT COUNT(*) FROM T WHERE ROWNUM <2
This will return '1' as the result. Oracle applies the 'rownum' to the
result
set and does then any aggregation (in this case counting)
In Informix:
SELECT FIRST 1 COUNT(*) from T
Will return one row, the result being nrows of the table T.
Informix gets the result set, then does all aggregation and only applies
the
'first n' to the final result that is being sent to the client.
HTH
Tilman