1
具有如下表my_tabe
連接:串聯領域使用前
M01 | 1
M01 | 2
M02 | 1
我想,以獲得超過其查詢:
M01 | 1,2
M02 | 1
我設法接近使用以下查詢:
with my_tabe as
(
select 'M01' as scycle, '1' as sdate from dual union
select 'M01' as scycle, '2' as sdate from dual union
select 'M02' as scycle, '1' as sdate from dual
)
SELECT scycle, ltrim(sys_connect_by_path(sdate, ','), ',')
FROM
(
select scycle, sdate, rownum rn
from my_tabe
order by 1 desc
)
START WITH rn = 1
CONNECT BY PRIOR rn = rn - 1
產量:
SCYCLE | RES
M02 | 1,2,1
M01 | 1,2
這是錯誤的。這似乎我很接近,但我恐怕我不會有什麼下一步...
任何提示?
O11g不錯!謝謝! – filippo 2011-06-15 17:02:13