- select stuid as 学号,name as 姓名,
- sum(case when subject='语文' then score else 0 end) as 语文,
- sum(case when subject='数学' then score else 0 end) as 数学,
- sum(case when subject='英语' then score else 0 end) as 英语,
- sum(score) as 总分,(sum(score)/count(*)) as 平均分
- from stuscore
- group by stuid,name
- order by 总分 desc
sql统计查询
最新推荐文章于 2023-07-12 10:38:32 发布