1、查询所有的课程数:
select count(cno) as zs from course;-- zs:总课程数的列名
2、查出学生学的课程数、学号姓名:
select s.sno,s.sname,count(sc.cno) AS zs1 FROM sc,student s where sc.sno=s.sno group by sc.sno; – zs1:学生学课程数的列名
3、根据上边的查询,写出最终答案:
select b.sno,b.sname from (
select count(cno) as zs from course
)a,(
select s.sno,s.sname,count(sc.cno) AS zs1 from sc,student s where sc.sno=s.sno group by sc.sno
) b
where a.zs=b.zs1;
4、字段解释:
course:课程表(字段:cno,cname)
student:学生表(字段:sno,sname)
sc:成绩表(字段:sno,score,cno)
cno:班级编号。
count():统计
group by:分组
查询没有学全所有课程同学的姓名,学号。
最新推荐文章于 2024-07-13 14:52:25 发布