Re: IDS Feature Request List (including potential new requests) - FETCH FIRST
Posted in 2006
Topics: SQL Development & Query Writing
bozon wrote:
> Finally, looking in the index of the book I don't see a single thing
> about "FETCH FIRST" which leads me to believe this is a non-standard
> construct which even enhances my "bastardization" arguement.
>
Agree. Consider theses staments:
------------------------------------------------
select count(*) from atab
where tabname > 'U%';
Result : (count(*))
4
1 row(s) retrieved.
------------------------------------------------
select first 1 count(*) from atab
where tabname > 'U%';
Result: (count(*))
4
1 row(s) retrieved.
---------------------------------------------------
So Informix applies the first <n> to the final result set
which gets sent to the client. For the 'select count(*)'
query this will always be 1 row (unless you have a group by
clause).
To my knowledge (don't beat me if I am mistaken), ORCLE applies
the equivalent (-- think it's it 'where rownum < <n>' ?? )
before the counting and grouping .
So you will receive quit different results.
The second query above will yield 1 row, the result will be '1' .
Haven't checked it out on DB2 .
>Model-Bosch, Tilman said ... > Thanks, yes the meaning of the "first" construct definitely changes based on when it is applied. I don't know if there is a standard for this construct.