Select Doff_No,
SL_BR,
LTRIM(Max(SYS_CONNECT_BY_PATH(output_code,',')),',')
,Count(1)
From (
SELECT ROW_NUMBER() OVER ( PARTITION BY Doff_No,
SubStr(SL_BR,2,1)
ORDER BY Doff_No,
SubStr(SL_BR,2,1) ) Rn,
Doff_No,
SubStr(SL_BR,2,1) SL_BR,
output_code
From SL_ActualRoll
Where Doff_No Like 'J182%'
and OutPut_Code is not Null
)
Where SL_BR is Not Null
Start With Rn = 1
CONNECT bY Prior Doff_NO = DOFF_NO /* 그룹 걸넘들이 다 and로 묶어야 한다. */
And Prior SL_Br = SL_BR
and Prior Rn = Rn - 1
Group By Doff_No, SL_BR

최신 댓글