链接
table
id | score
1 | 10
1 | 20
2 | 10
2 | 30
to
id | score
1 | 10,20
2 | 10,30
select id,STUFF((select ','+score from table t1 where t1.id=t.id for xml path(''),1,1,'') as score from table t group by id
group_concat
concat_ws
一行变多行
链接
Hive sql中可以使用
lateral view 和explode()
select id ,scores from table lateral view explode(split(score,','))t1 as scores
网友评论