`
sjk2013
  • 浏览: 2183521 次
文章分类
社区版块
存档分类
最新评论

DB2多行转一行【XML方式】

阅读更多
分组然后合并,然后去除XML标签
SELECT replace(replace(replace(xml2clob(xmlagg(xmlelement(name A, 【字段】))),'</A><A>', '【分隔符】'),'</A>',''),'<A>','')   
from 【表】
group by 【分组字段】


如:

SELECT replace(replace(replace(xml2clob(xmlagg(xmlelement(name A, nounid))),'</A><A>', ','),'</A>',''),'<A>','')
from SYS_NOUN
group by nounsuper

这种方式运行速度很快。
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics