db2笔记_4_字段值合并输出
用逗号隔开(开头末尾都没逗号)
SELECT colName1,LISTAGG(colName2, ',') FROM tableName GROUP BY colName1
在oracle中:LISTAGG(XXX,XXX) WITHIN GROUP( ORDER BY XXX)
用逗号隔开(末尾有逗号)
SELECT colName1,replace(replace(xml2clob(xmlagg(xmlelement(NAME a, colName2||','))),'<A>',''),'</A>',' ')
FROM tableName
GROUP BY colName1
两字段合并输出
SELECT colName1 || colName2 FROM tableName