永发信息网

1查询成绩表的总分数,平均分,最低分和最高分。用sql语句怎么写?

答案:1  悬赏:0  手机版
解决时间 2021-11-09 18:14
  • 提问者网友:寂寞梧桐
  • 2021-11-09 01:33
1查询成绩表的总分数,平均分,最低分和最高分。用sql语句怎么写?
最佳答案
  • 五星知识达人网友:猎心人
  • 2021-11-09 02:33
1. 计算每个人的总成绩并排名(要求显示字段:姓名,总成绩)
select name,sum(cast(score as bigint)) as allscore from stuscore group by name order by allscore desc
2. 计算每个人的总成绩并排名(要求显示字段: 学号,姓名,总成绩)

select stuid,name,sum(cast(score as bigint)) as allscore from stuscore group by stuid,name order by allscore desc
3. 计算每个人单科的最高成绩(要求显示字段: 学号,姓名,课程,最高成绩)
SELECt t1.stuid,t1.name,t1.subject,t1.score from stuscore t1,(SELECt stuid,max(score) as maxscore from stuscore group by stuid) t2 where t1.stuid=t2.stuid and t1.score=t2.maxscore
4. 计算每个人的平均成绩(要求显示字段: 学号,姓名,平均成绩)
select distinct t1.stuid,t1.name,t2.avgscore from stuscore t1,(select stuid,avg(cast(score as bigint)) as avgscore from stuscore group by stuid) t2 where t1.stuid=t2.stuid
我要举报
如以上回答内容为低俗、色情、不良、暴力、侵权、涉及违法等信息,可以点下面链接进行举报!
点此我要举报以上问答信息
大家都在看
推荐资讯