DB2中怎样把同一张表中相同字段的内容合并为一条记录 急啊 求高…
db2吧
全部回复
仅看楼主
level 3
wylawan 楼主
name type
张三 游戏
张三 游泳
李四 爬山
李四 打球
王五 上网
王五 泡妞
拼接sql 显示结果:
张三, 游戏 游泳
李四, 爬山 打球
王五, 上网 泡妞
问题补充:我用的V8。0。1 怎写啊 求高手指教
2012年11月29日 05点11分 1
level 3
wylawan 楼主
人呢 告诉 呢
2012年11月29日 06点11分 2
level 3
with temp as
(select name,max(case when num=1 then type end) as q1,max(case when num=2 then type end) as q2 from (select name,type,row_number()over(partition by name) as num from dw_test.rechange group by name,type)
group by name)
select name,q1||','||q2 as type from temp group by name,q1,q2;
2013年06月03日 06点06分 4
1