SELECT
proIndex,
tftProjectNm,
tftStartDt,
tftEndDt,
tftStatus,
SUBSTR(MAX(SYS_CONNECT_BY_PATH(tftMemberId,',')),2) tftMemberId,
SUBSTR(MAX(SYS_CONNECT_BY_PATH(tftMemberNm,',')),2) tftMemberNm
FROM (
SELECT
proIndex,
proIndex || trim(to_char(RNUM-1, '00')) UpIndex,
proIndex || trim(to_char(RNUM, '00')) DnIndex,
tftProjectNm,
tftStartDt,
tftEndDt,
tftStatus,
tftMemberId,
tftMemberNm,
RNUM
FROM (
SELECT
TFT010_INDEX proIndex,
TFT010_PROJECT_NM tftProjectNm,
to_char(to_date(TFT010_START_DT,'yyyy-mm-dd'),'yyyy-mm-dd') tftStartDt,
to_char(to_date(TFT010_END_DT,'yyyy-mm-dd'),'yyyy-mm-dd') tftEndDt,
TFT010_STATUS tftStatus,
TFT020_MEMBER_ID tftMemberId,
(SELECT SSO001_KOR_NM FROM SSO.SSO001TL WHERE SSO001_ONE_ID=TFT020_MEMBER_ID) as tftMemberNm,
row_number() over(partition by TFT010_INDEX ORDER BY TFT020_MEMBER_ID) RNUM
FROM TFT010TL A, TFT020TL B
WHERE A.TFT010_INDEX = B.TFT020_INDEX
AND TFT010_STATUS <> 'M'
)
)
START WITH UpIndex in ( SELECT TFT010_INDEX || '00'
FROM TFT010TL A, TFT020TL B
WHERE A.TFT010_INDEX = B.TFT020_INDEX
and TFT010_STATUS <> 'M'
and TFT020_MEMBER_ID = 'lsg'
)
CONNECT BY PRIOR DnIndex = UpIndex
GROUP BY proIndex, tftProjectNm, tftStartDt, tftEndDt, tftStatus
댓글 없음:
댓글 쓰기