DB2分页查询sql和ROW_NUMBER()函数

 

1. db2分页查询sql

 

select * from (

         select ROW_NUMBER() OVER(ORDER BY DOC_UUID DESC) AS ROWNUM, DOC_UUID, DOC_DISPATCHORG,       DOC_SIGNER, DOC_TITLE    from DT_DOCUMENT  ) a 

where ROWNUM > 20 and ROWNUM <=30

 

 

2.ROW_NUMBER()函数

 

增加行号,不排序

select * from ( select ROW_NUMBER() OVER() AS ROWNUM,t.*  from DT_DOCUMENT  t ) a

增加行号,按某列排序

select * from ( select ROW_NUMBER() OVER( ORDER BY DOC_UUID DESC ) AS ROWNUM,t.*  from DT_DOCUMENT  t ) a

你可能感兴趣的:(DB2技术)