close

[Oracle] Group Concat for 9i在Oracle每個版本中不一定有支援group concat 的方法, 其中, 9i並沒有一個function可以得到像mysql這樣的結果,而 10g 可以用 Collect() 方法9i 要如何做才可以得到這樣的結果 ?以下是一個範例:一個table=test1 存放有id username hobbit--------------------------------1 tony 玩2 tony 聊天3 mary 看電影query: with data as ( select username, hobbit, row_number() over (partition by username order by username) rn, count(*) over (partition by username) cnt from test1 ) select username, ltrim(sys_connect_by_path(hobbit,','),',') scbp from data where rn = cnt start with rn = 1 connect by prior username = username and prior rn = rn-1 order by username;結果:username scbp------------------------mary 看電影tony 玩,聊天10g的部份等安裝後再來測試! .msgcontent .wsharing ul li { text-indent: 0; } 分享 Facebook Plurk YAHOO! .


arrow
arrow
    全站熱搜
    創作者介紹
    創作者 zd0000105 的頭像
    zd0000105

    自由行

    zd0000105 發表在 痞客邦 留言(0) 人氣()