teradata 字符串数据合并 在concat()函数无法使用的情况下

在teradata sql中不存在concat()函数或者stuff()函数,在此情况下,如何实现多条字符串数据合并成一行?

在查找不同方法过程中,在stackflow中找到最简便的方法,使用xml_agg()函数

https://stackoverflow.com/questions/45306260/concatenate-strings-from-multiple-records-in-teradata-sql

本文问题

数据如下图所示:

目标结果:

sql:

select item_site_id ,trim(trailing ',' from(xmlagg(item_id || ',' order by item_site_id )(varchar(500))))
from tab1
group by 1

  

原文地址:https://www.cnblogs.com/papio/p/9467730.html