实验四
2、查询每个学生的平均成绩;(输出学号、姓名、平均成绩)
Selectsc.sno,sname,avg(grade)
Fromsc,student
Wherestudent.sno = sc.sno
Group bysc.sno ,sname;
5、查询选择了1号课或3号课的学生姓名;
Selectsname
Fromstudent
Wheresno in(
Select sno
From sc
Where cno = ‘1’ or cno = ‘3’
);
6、查询每个学院的学生人数
Select sdept,count(*)
Fromstudent
Group bysdept;
8、查询跟刘晨一个院系的学生学号、姓名
Select sno,sname
Fromstudent
Wheresdept in(
Select sdept
From student
Where sname = ‘刘晨’) andsname not like ‘刘晨’;
9、查询选修人数超过2的课程号、课程名
Selectcname,cno
Fromcourse
Wherecno in(
Select cno
From sc
Group by cno
Having count(*) >2);
10、查询男女生人数
Select count(*) number
Fromstudent
Group byssex;
11、按总成绩降序显示学生的学号、姓名、总成绩
Selectsc.sno,sname,sum(grade)
Fromstudent,sc
Wheresc.sno = student.sno
Group sc.sno,sname
Order bysum(grade) desc;