Combine multiple rows into one space separated string

后端 未结 4 692
时光取名叫无心
时光取名叫无心 2020-12-30 05:05

So I have 5 rows like this

userid, col
--------------
1, a
1, b
2, c
2, d
3, e

How would I do query so it will look like this



        
4条回答
  •  盖世英雄少女心
    2020-12-30 05:36

    In hive you can use

    SELECT userid, collect_set(combined) FROM tabel GROUP BY user_id;
    

    collect_set removes duplicated. If you need to keep them you can check this post:

    COLLECT_SET() in Hive, keep duplicates?

提交回复
热议问题