PostgreSQL 的string_agg()的使用
-- 查询错误等级为32的客户
select
customer_id,
error_level
from
cda_cs_tt_error
where
error_level = '32'
使用 string_agg() 将多行合并成一行:
SELECT
error_level,
string_agg ( customer_id, ';' ) AS customer
FROM
cda_cs_tt_error
WHERE
error_level='32'
GROUP BY
error_level;
mysql:group_concat( distinct 要连接的字段 order by 排序字段 asc/desc separator ‘分隔符’ )
oracle:listagg(要连接的字段,‘分隔符’) WITHIN GROUP ()