使用教学(STC)数据库,请将实现以下功能的SQL语句填写完整:: (9)查询只有5名(含5名)以下学生选修的课程信息,包括课程名、选修人数(同一个学生重复选修,只计1人),并按选修人数降序排序。[br][/br] select cname,count( sno) 选修人数 from course,sc where course.cno=sc.cno group by sc.cno,cname having (distinct sno)<=5 order by desc
举一反三
- 查询选修了'数据库基础'课程的同学的学号,和这些同学选修的全部课程号和分数.select sno,cno,gradefrom ______________________ A: sc where sno in (select sno from sc join course on sc.cno=course.cno where cname='数据库基础') B: sc join course on sc.cno=course.cno where cname='数据库基础' C: sc where sno in (select sno from course where cname='数据库基础') D: sc where cno in (select cno from course where cname='数据库基础')
- 基于“学生-选课-课程”数据库中的三个关系: 学生表S(SNO,SNAME,SEX,BIRTHYEAR,DEPT),主码为SNO 课程表C(CNO,CNAME,TEACHER),主码为CNO 选课表SC(SNO,CNO,GRADE),主码为(SNO,CNO) [br][/br]查找“选修了至少5门课程的学生的学号”,正确的SQL语句是( )。 A: SELECT SNO FROM SC GROUP BY SNO HAVING COUNT(*) >=5; B: SELECT SNO FROM SC GROUP BY SNO WHERE COUNT(*) >=5; C: SELECT SNO FROM SC HAVING COUNT(*) >=5; D: SELECT SNO FROM SC WHERE COUNT(*) >=5;
- 在MySQL中,假设有学生选课表SC(sno,cno,score)。那么列出所有选修课程超过5门的学生学号以及选修课程数目,其正确的SQL语句为()。 A: select sno,count(cno)from scwhere count(cno)>=5; B: select sno,count(cno)from scgroup by sno where count(cno)>=5; C: select sno,count(cno)from scgroup by sno having count(cno)>=5; D: select sno,count(cno)from scgroup by cno having count(cno)>=5;
- 同时选修了‘数据结构’和‘操作系统’2门课程的同学学号、姓名。select student.sno,sname from student,sc,coursewhere student.sno=sc.sno and course.cno=sc.cnoand _________________________________________________ A: cname='数据结构' and student.sno in(select sno from sc,course where sc.cno=course.cno and cname='操作系统') B: cname='操作系统' and student.sno in(select sno from sc,course where sc.cno=course.cno and cname='数据结构') C: cname='数据结构' and cname='操作系统' D: student.sno in(select sno from sc,course where sc.cno=course.cno and cname='操作系统'and cname='数据结构')
- 查询选修了数学课(课程号为2)的学生人数,可以使用的查询语句是: 。 A: SELECT MAX(*) FROM SC WHERE Cno = 2; B: SELECT AVG(Sno) FROM SC WHERE Cno = 2; C: SELECT COUNT(*) FROM SC WHERE Cno = 2; D: SELECT COUNT(Sname) FROM SC WHERE Cno = 2;