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:

http://publib.boulder.ibm.com/infocenter/dzichelp/v2r2/index.jsp?topic=/com.ibm.db29.doc.perf/db2z_fetchfirstnrows.htm

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

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -