看了一下你这结果不是出来了,只需要再加个排序就可以和你想要的结果一致 select `t1`.`user_name` AS `user_name`,'h_score' AS `维度`,sum((case when (`course` = '英语') then `h_score` else 0 end)) AS `英语`, sum((case when (`course` = '俄语') then `h_score` else 0 end)) AS `俄语`, sum((case when (`course` = '日语') then `t1`.`h_score` else 0 end)) AS `日语` from `t1` group by `user_name` union select `user_name` AS `user_name`,'wscore' AS `维度`,sum((case when (`course` = '英语') then `w_score` else 0 end)) AS `英语`,sum((case when (`course` = '俄 语') then `w_score` else 0 end)) AS `俄语`, sum((case when (`course` = '日语') then `w_score` else 0 end)) AS `日语` from `t1` group by `user_name` order by `user_name`; 😀😋
2 1

相关推荐

点赞 评论 收藏
分享
牛客717484937号:双飞硕没实习挺要命的
点赞 评论 收藏
分享
牛客网
牛客企业服务