mysql统计各个科目的分数、总分、平均分
SELECT s.id, s.name,
max(case when g.kemu='语文' then score else 0 end) as 语文,
max(case when g.kemu='数学' then score else 0 end) as 数学,
max(case when g.kemu='英语' then score else 0 end) as 英语,
sum(score) as 总分,
avg(score) as 平均分
from student s LEFT JOIN grade g ON s.id = g.s_id GROUP BY s.id;
————————————————
版权声明:本文为CSDN博主「幼儿园二园长」的原创文章,遵循CC 4.0 BY-SA版权协议,转载请附上原文出处链接及本声明。
原文链接:https://blog.csdn.net/weijiaxin2010/article/details/88065351