DB2多行转一行【XML方式】
2017-04-23 17:21 tlnshuju 阅读(967) 评论(0) 收藏 举报
分组然后合并,然后去除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
浙公网安备 33010602011771号