DB2里面如何进行快速分页?就像mysql的limit之类的
发布网友
发布时间:2022-04-08 06:07
我来回答
共3个回答
热心网友
时间:2022-04-08 07:36
DB2 只查询前10行 fetch first 10 rows only
例如:
SELECT
SALE_DATE,
SUM(SALE_MONEY) AS SUM_MONEY
FROM
SALE_REPORT
GROUP BY
SALE_DATE
ORDER BY
SUM(SALE_MONEY) DESC
fetch first 10 rows only;
如果要查询 11 - 20
使用
(fetch first 20 rows only) fetch first 10 rows only
例如:
SELECT
top20.*
FROM
(
SELECT
SALE_DATE,
SUM(SALE_MONEY) AS SUM_MONEY
FROM
SALE_REPORT
GROUP BY
SALE_DATE
ORDER BY
SALE_DATE DESC
fetch first 20 rows only
) AS top20
ORDER BY
top20.SALE_DATE ASC
fetch first 10 rows only;
热心网友
时间:2022-04-08 08:54
select * from (select ROW_NUMBER() over() as a, wf_staff.* from wf_staff) as temp where a>=6 and a<=8;
热心网友
时间:2022-04-08 10:29
select * from ( select rownumber() over() as rownum, ### from ### where ### ) tempT
where rownum > ### and rownum <= ###DB2 9.7.2可以支持SELECT * FROM TABLE LIMIT 5 AND 20