( SELECT stuid as id, CAST(sum(case when `subject`='math' then score end) AS SIGNED) as math, CAST(sum(case when `subject`='english' then score end) AS SIGNED) as english, CAST(( sum(case when `subject`='math' then score end) + sum(case when `subject`='english' then score end) ) AS SIGNED) as 'sum' FROM score GROUP BY stuid ) UNION ( SELECT 'avg' as id, CAST(avg(case when `subject`='math' then score end) AS SIGNED) as math, CAST(avg(case when `subject`='english' then score end) AS SIGNED) as english, CAST(( avg(case when `subject`='math' then score end) + avg(case when `subject`='english' then score end) ) AS SIGNED) as 'sum' FROM score )
点赞 评论

相关推荐

03-08 18:11
门头沟学院 Java
Java抽象小篮子:海投就完事了,简历没什么问题,最大问题是学历
点赞 评论 收藏
分享
牛客网
牛客网在线编程
牛客网题解
牛客企业服务