在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;
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;
举一反三
- 统计每门课程的选课人数select cno , _________from scgroup by ________ A: count(*) ; cno B: count(sno) ; cno C: count(*) ; sno D: count(sno) ; sno
- 基于“学生-选课-课程”数据库中的三个关系: 学生表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;
- 针对学生选课表sc(sno, cno, grade),其中sno为学号,cno为课程号,grade为成绩。以下( )语句可查询选修了两门以上成绩在90分以上课程的学生学号。 A: select sno from sc where grade>90 group by sno having count(cno)>2; B: select sno from sc where grade>90 group by sno having count(*)>2; C: select sno from sc where grade>90 and count(*)>2 group by sno; D: select sno from sc where grade>90 group by sno having count(sno)>2;
- 针对学生选课表sc(sno, cno, grade),其中sno为学号,cno为课程号,grade为成绩。以下( )语句可查询选修了两门以上成绩在90分以上课程的学生学号。 A: select sno from scwhere grade>90group by snohaving count(cno)>2 B: select sno from scwhere grade>90group by snohaving count(*)>2 C: select sno from scwhere grade>90 and count(*)>2group by sno D: select sno from scwhere grade>90group by snohaving count(sno)>2
- 查询选课门数大于3门的同学学号,姓名, 选课门数Select ______________from student s, scwhere s.sno=sc.sno group by __________having _____________ A: sno, sname, count(*) ; sno, sname; count(*)>3 B: sno, sname, count(*) ; sno; count(*)>3 C: sno, sname, count(cno) ; sno; count(cno)>3 D: sno, sname, count(sno) ; sno; count(sno)>3