The paging query method of DB2 is not the same as that of paging query statements in Oracle and SQL. The following describes the differences between paging query in DB2 and paging query in other databases.
Oracle paging query statement:
I. Oracle
Select * from (selectRownum, Name from table whereRownum <= endindex and rownum> startindex)
Ii. DB2
DB2 paging Query
- Select * from (select Field 1, Field 2, Field 3,Rownumber () over (column name ASC used for order by sorting) as RnFrom table name) as A1 where a1.rnBetween 10 and 20
The above indicates that 10th to 20 records are extracted.
Select * from (selectRownumber () over (order by id asc) as rowidFrom table whereRowid<= Endindex and rowid>Startindex)
Note: The preceding DB2 SQL statements are available in IBM DB2 UDBV8.2And
V9.7After the test is passedRownumber ()ChangeRow_number (), Verification passed.
Iii. MySQL:
Select * from tableLimit start, pagenum
original article address: http://database.51cto.com/art/201011/232337.htm