Equivalent of LIMIT for DB2 -
how do limit
in db2 iseries?
i have table more 50,000 records , want return records 0 10,000, , records 10,000 20,000.
i know in sql write limit 0,10000
@ end of query 0 10,000 , limit 10000,10000
@ end of query 10000 20,000
so, how done in db2? whats code , syntax? (full query example appreciated)
using fetch first [n] rows only
:
select lastname, firstname, empno, salary emp order salary desc fetch first 20 rows only;
to ranges, you'd have use row_number()
(since v5r4) , use within where
clause: (stolen here: http://www.justskins.com/forums/db2-select-how-to-123209.html)
select code, name, address ( select row_number() on ( order code ) rid, code, name, address contacts name '%bob%' ) t t.rid between 20 , 25;
Comments
Post a Comment