三种SQL实现聚合字段合并(presto、hive、mysql)

需求:按照项目名,以逗号合并参与人

三种SQL实现聚合字段合并(presto、hive、mysql)

presto

select 
    item_name
    ,array_join(array_agg(name),',') as group_name
from 
    test.test_04
group by 
    item_name
order by item_name 

在这里插入图片描述

hive

select 
    item_name
    ,concat_ws(',',collect_set(name)) as group_name
from 
    test.test_04
group by 
    item_name
order by item_name 

在这里插入图片描述

mysql

select 
    item_name,
    group_concat(name,',') as group_name 
from 
    test_prc
group by item_name

在这里插入图片描述

本文来自网络,不代表协通编程立场,如若转载,请注明出处:https://net2asp.com/db399d6ed8.html