db2分页语句

SELECT
    *
FROM
    (
        SELECT
           <span style="color:#ff0000;"> rownumber() over(
            ORDER BY
                A.PROPOSALNO
            ) AS rownumber_</span> ,
            A.*
        FROM
            PRPTMAIN A ,
            PRPTITEMCAR B
        WHERE
            A.PROPOSALNO = B.PROPOSALNO
        ORDER BY
            A.PROPOSALNO
    ) AS temp_
WHERE
    rownumber_ BETWEEN 1 AND 5
buffer.append("select * from ( select rownumber() over(");
                int orderByIndex = sql.toLowerCase().indexOf("order by");
                if ( orderByIndex>0 ) {
                   buffer.append( sql.substring(orderByIndex) );
                }
                buffer.append(") as rownumber_,");
                buffer.append(sql.substring( 6 ));
                buffer.append(" ) as temp_ where rownumber_");
                buffer.append(" between "+ (rowsPerPage * (pageNo - 1) + 1) +" and "+rowsPerPage * pageNo);


你可能感兴趣的:(db2,分页)