需求:根据class分组,把同一分组的name字段使用逗号分隔
原始表:
结果集:
Spark sql 实现 :
SELECT concat_ws(',',collect_set(name)) FROM A GROUP BY class
去重并拍排序
SELECT concat_ws(',',sort_array(collect_set(nvl(rap_flag,'false'))) FROM A GROUP BY class
原创文章,作者:3628473679,如若转载,请注明出处:https://blog.ytso.com/tech/pnotes/277545.html