( 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 )
点赞 评论

相关推荐

11-09 01:22
已编辑
东南大学 Java
高级特工穿山甲:羡慕,我秋招有家企业在茶馆组织线下面试,约我过去“喝茶详谈”😢结果我去了发现原来是人家喝茶我看着
点赞 评论 收藏
分享
牛客网
牛客企业服务