selectsuperid , string_agg(tag_value,',' order by tag_value) as tag_value
from (
select superid,tag_value
from (
select
b.superid,
(case when trim(a.order_channel)='CMS' then '可控门店'
when trim(a.order_channel)='EOS' then '焕新服务'
when trim(a.order_channel)='E3' then order_source
else '微商城'
end )as tag_value
from cdp_order_model a
join superid_all b on a.customer_id = b.id and b.idtype ='jiami_mobile'
where channel='cdp_order_sale_01'
) c
group by c.superid,c.tag_value
)a
group by superid
> 11111可控门店,焕新服务
2222可控门店,焕新服务
3333可控门店