9999热视频三级毛片AV区|日韩欧美精品狼友观看视频|av在线成人免费AA片|日韩三级AV电影|久久亚洲私人国产精品vA|亚洲无码卡一卡二卡三|手机在线免费看黄色片|婷婷尹人在线婷婷五月手机网|99爱在线播放|欧美成人色情视频品

oracle列值合併
來源:易賢網(wǎng) 閱讀:1523 次 日期:2014-10-21 14:13:16
溫馨提示:易賢網(wǎng)小編為您整理了“oracle列值合併”,方便廣大網(wǎng)友查閱!

合併列值最通用的方法就是寫一個自定義函數(shù)去實現(xiàn),這裏介紹的是其他方法。

在sql server中合併列值可以使用for xml path,在oracle中則可以使用wm_concat 或 listagg。

準備數(shù)據(jù):

create table mytest(xtype number,city nvarchar2(200));

/

insert into mytest(xtype,city)

select 1,n'北京' from dual union all

select 1,n'上海' from dual union all

select 1,n'廣州' from dual union all

select 2,n'武漢' from dual union all

select 2,n'杭州' from dual union all

select 2,n'廈門' from dual

commit;

/

使用wm_concat:

select xtype,wmsys.wm_concat(to_char(city)) as xcity

from mytest

group by xtype

使用listagg:

select xtype,

listagg(to_char(city),',') within group(order by xtype) as xcity

from mytest

group by xtype

結果:

xtype xcity

---------- --------------------------------------

1 北京,廣州,上海

2 杭州,武漢,廈門

備註:

0、上面在city列前都加了to_char()函數(shù),是為了防止出現(xiàn)亂碼的情況;

1、wm_concat 在oracel的官方文檔中沒有,不能保證各版本的兼容性;

2、listagg是11g版本才出現(xiàn)的新的聚集函數(shù)。

更多信息請查看IT技術專欄

更多信息請查看數(shù)據(jù)庫
下一篇:oracle xml 轉換
易賢網(wǎng)手機網(wǎng)站地址:oracle列值合併
關于我們 | 聯(lián)系我們 | 人才招聘 | 網(wǎng)站聲明 | 網(wǎng)站幫助 | 非正式的簡要咨詢 | 簡要咨詢須知 | 新媒體/短視頻平臺 | 手機站點

版權所有:易賢網(wǎng)