sql语句的使用——查询每个学生的总分和平均分,有一张表

2024-11-20 08:34:04
推荐回答(4个)
回答(1):

select sno, sum(grade) as total ,avg(grade) as average
from sc
group by sno

回答(2):

select sum(grade)总成绩,avg(grade) 平均成绩from sc where sno in(select sno from sc where sno in('1001','1002','1003','1004','1005'))

回答(3):

select sum(grade) as 总分 ,avg(grade) as 平均分 from sc group by sno

回答(4):

select sno, sum(grade) over(partiton by sno ) 总分,avg(grade) over(partition by sno) 平均分
from sc