查詢的方式為1-4 7-9 13- 17
-------------查詢不連續的流水碼---------------------
SELECT MIN (b.seq) Start_HM, MAX (b.seq) End_HM
FROM (SELECT a.*, TO_NUMBER (a.seq - ROWNUM) cc
FROM (SELECT *
FROM LWH_TEST
ORDER BY seq) a) b GROUP BY b.cc
示例:
SELECT MIN (b. csn) start_hm, MAX (b.csn) end_hm
FROM (SELECT a.*, TO_NUMBER (a.customer_sn - ROWNUM) cc
FROM (SELECT substr(customer_sn,-8) customer_sn,customer_sn csn
FROM g_sn_status where WORK_ORDER ='24020680-1.1-001-P'
ORDER BY customer_sn) a) b
GROUP BY b.cc
回复 更多评论