分组后的数据多行聚合成一行
两步走
- 先分组
- 再拼接
with temp as ( select id as id, class as class, sum(tag) as cnt from `xxx` group by id, class order by tag desc ) select t.id, concat_ws(',', collect_list(t.class)) from temp t group by t.idHIVE语法大全
官方文档
https://cwiki.apache.org/confluence/display/Hive/LanguageManual+UDF#LanguageManualUDF-json_tuple
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)