hive中的wm_concat 同列非数字字符串的拼接

oracle:

http://blog.csdn.net/lxpbs8851/article/details/7179291

 

之前写了个oracle 不支持 wm_concat 的解决办法。

 

现在在hive中遇到同样的问题,该如何解决?

sys_region(id,name)

1    a   

1    b   

2    c   

2    d   

想要得到结果

1  a,b

2  c,d

 

实现办法:

利用函数 collect_set

select id,concat_ws(',',collect_set(name))

from sys_region

group by id;

 

 

 

你可能感兴趣的:(hive中的wm_concat 同列非数字字符串的拼接)