select studentId,studentName,(select score from student where subject='语文') 语文分数,(select score from student where subject='数学') 数学分数,(select score from student where subject='英语') 英语分数,sum(score) 总分 from student group by studentName;
1条回答 默认 最新
- 曦陽惜夏 2021-07-24 09:30关注
SELECT studentName, max(CASE subject WHEN '语文' THEN score END ) as '语文', max(CASE subject WHEN '数学' THEN score END ) as '数学', max(CASE subject WHEN '英语' THEN score END ) as '英语' FROM student GROUP BY studentName
```
本回答被题主选为最佳回答 , 对您是否有帮助呢?解决 无用评论 打赏 举报