表A 表B 从表A到表B MySQL 写法:select name, group_concat(score seperate ';') as score from A group by name spark 写法:df.groupBy('name').agg(collect_list('score').alias('score')).show()//还可以使用collect_set去重 表C 从表A到表C select name, max(case type when '数学' then sco…
数据库结构如图: 而我想让同一个人的不同成绩变成此人在这一行不同列上显示出来,此时分为2中展现: 第一种展现如图----[多行变一列](合并后的数据在同一列上): sql如下: select name ,group_concat(sore Separator ';') as score from stu group by name 第二种展现如图----[多行变多列](合并后的数据在不同列上): sql如下: SELECT name , MAX(CASE type WHEN '数学' THEN…