一、分页查询
原始查询语句
SELECT * FROM NASLE_WFSHH
修改为分页查询语句,加上 ROWNUM 列。此处为查询第 1 页,每页 9 条数据
SELECT
*
FROM
( SELECT ROWNUM rn, a.* FROM NASLE_WFSHH a )
WHERE
rn BETWEEN 9 * 0 + 1 AND 9 * 1
二、排序分页查询
原始排序查询语句
SELECT * FROM NASLE_WFSHH ORDER BY WFSJ DESC
排序分页查询语句,分两步
1.添加 ROWNUM 列,不能在查询时添加,它会先生成 ROWNUM 列,再按照字段排序
SELECT
ROWNUM rn, temp.*
FROM
( SELECT * FROM NASLE_WFSHH ORDER BY WFSJ DESC ) temp
2.排序分页查询语句
SELECT
*
FROM
(
SELECT
ROWNUM rn, temp.*
FROM
( SELECT * FROM NASLE_WFSHH ORDER BY WFSJ DESC ) temp
)
WHERE
rn BETWEEN 9 * 0 + 1 AND 9 * 1