方法1:
SELECT
KSBH
,SUBSTR(MAX(RESULT),2) AS KSKMBM FROM
(
SELECT KSBH,KSKMBM,SYS_CONNECT_BY_PATH(KSKMBM,',') RESULT FROM
(
SELECT KSBH, KSKMBM, RN, LEAD(RN) OVER(PARTITION BY KSBH ORDER BY RN)
RN1 FROM
(
--my sql begin
SELECT
KSXX.KSBH,
CSCJ.KSKMBM,
ROW_NUMBER() OVER(ORDER BY KSXX.KSBH) RN
FROM
IDC_U_YJSJW.YJSJW_KSGRJBXX KSXX,
IDC_U_YJSJW.YJSJW_KSCSCJXX CSCJ
WHERE
KSXX.KSBH = CSCJ.KSBH
--my sql end
)
)
START WITH RN1 IS NULL CONNECT BY RN1 = PRIOR RN ORDER BY RN
)
GROUP BY KSBH
方法2:
http://community.csdn.net/Expert/TopicView2.asp?id=4312073&datebasetype=now