数据表的记录如下
5112 960024
5112 960025
5112 960026
5112 960027
5112 960028
5113 960043
5113 960044
5113 960045
5113 960046
select product_id, concat_ws('_',collect_set(promotion_id)) as promotion_ids from product_promotion group by product_id
执行结果:
5112 960024_960025_960026_960027_960028
5113 960043_960044_960045_960046
Time taken: 3.116 seconds
collect_list: 合成数值, 但是有重复
collect_set: 合成数组,但是已去重