实验四 数据库试验-单表查询(3)
时间:2025-03-11
时间:2025-03-11
数据库试验报告-单表查询
select count(sno) from sc group by cno ;
11、使用聚合函数
(1)查询学生总人数。
T-SQL语句:
select count(sno) from student ;
(2)计算“002”号课程的学生平均成绩、最高分、最低分。 T-SQL语句:
select avg(grade),max(grade),min(grade) from sc where cno='002';
(3)汇总每个学生的学号及总成绩。
T-SQL语句:
select sno,sum(grade) from sc group by sno;