我的测试表里有7条数据。每3条数据分作一组求最小和最大id。
WITH tmp ("id") AS
(SELECT 1 FROM DUAL UNION ALL
SELECT 2 FROM DUAL UNION ALL
SELECT 3 FROM DUAL UNION ALL
SELECT 4 FROM DUAL UNION ALL
SELECT 5 FROM DUAL UNION ALL
SELECT 6 FROM DUAL UNION ALL
SELECT 7 FROM DUAL
)
select min("id") min_id,max("id") max_id
from (
select "id",row_number() over (order by "id") seq from tmp
) t
group by floor((seq-1)/3)
order by floor((seq-1)/3)
结果如下:
楼主把上面语句里的3换成100就行了。