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:分组
来源:CSDN
作者:清风qing
链接:https://blog.csdn.net/qq_43253922/article/details/104423994