1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| -- 第一步 将元素聚拢 select id1, id2, collect_set(flag) flag from rowline2 group by id1, id2;
select id1, id2, collect_list(flag) flag from rowline2 group by id1, id2;
select id1, id2, sort_array(collect_set(flag)) flag from rowline2 group by id1, id2;
-- 第二步 将元素连接在一起 select id1, id2, concat_ws("|", collect_set(flag) ) flag from rowline2 group by id1, id2;
-- 这里报错,CONCAT_WS must be "string or array<string>"。加一个 类型转换即可 select id1, id2, concat_ws("|", collect_set(cast (flag as string)) ) flag from rowline2 group by id1, id2;
|