|
发表于 2020-3-8 11:15:02
|
显示全部楼层
select ID,min(PJHM), max(PJHM)
from (
select ID, PJHM - rownum as c, rownum, PJHM from (
SELECT * FROM (
SELECT 1 AS ID, '001' AS PJHM FROM DUAL UNION ALL
SELECT 1 AS ID, '002' AS PJHM FROM DUAL UNION ALL
SELECT 1 AS ID, '003' AS PJHM FROM DUAL UNION ALL
SELECT 1 AS ID, '005' AS PJHM FROM DUAL UNION ALL
SELECT 1 AS ID, '006' AS PJHM FROM DUAL UNION ALL
SELECT 2 AS ID, '001' AS PJHM FROM DUAL UNION ALL
SELECT 2 AS ID, '005' AS PJHM FROM DUAL UNION ALL
SELECT 2 AS ID, '006' AS PJHM FROM DUAL
)order by ID,PJHM)
)group by ID,c
ORDER BY 1, 2 ; |
|