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

2024年11月20日 08:34
有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