标签:转行 _id xpl concat_ws hive view from one nbsp
1.列转行
select t.cust_id
,concat_ws(‘,‘,collect_list(group_id)) one_pace
from (select ‘A_001‘ cust_id
,‘20191014‘ group_id
union all
select ‘A_001‘ cust_id
,‘20191015‘ group_id
union all
select ‘A_001‘ cust_id
,‘20191016‘ group_id) t
group by t.cust_id;
2.行转列
select cust_id
,one_pace
,group_id
from (select ‘A_001‘ cust_id
,‘20191014,20191015,20191016‘ one_pace
union all
select ‘A_002‘ cust_id
,‘20191014,20191015,20191016‘ one_pace
union all
select ‘A_003‘ cust_id
,‘20191014,20191015,20191016‘ one_pace) t
lateral view explode(split(one_pace,‘,‘)) num as group_id;
标签:转行 _id xpl concat_ws hive view from one nbsp
原文地址:https://www.cnblogs.com/Arabi/p/11678314.html