预览加载中,请您耐心等待几秒...
1/3
2/3
3/3

在线预览结束,喜欢就下载吧,查找使用更方便

如果您无法下载资料,请参考说明:

1、部分资料下载需要金币,请确保您的账户上有足够的金币

2、已购买过的文档,再次下载不重复扣费

3、资料包下载后请先用软件解压,在使用对应软件打开

Student(S#,Sname,Sage,Ssex)学生表Course(C#,Cname,T#)课程表SC(S#,C#,score)成绩表Teacher(T#,Tname)教师表 问题:1、查询“001”课程比“002”课程成绩高的所有学生的学号;selecta.S#from(selects#,scorefromSCwhereC#='001')a,(selects#,scorefromSCwhereC#='002')bwherea.score>b.scoreanda.s#=b.s#;2、查询所有同学的学号、姓名、选课数、总成绩;selectStudent.S#,Student.Sname,count(SC.C#),sum(score)fromStudentleftOuterjoinSCon Student.S#=SC.S#groupbyStudent.S#,Sname 3、查询姓“李”的老师的个数;selectcount(distinct(Tname))fromTeacherwhereTnamelike'李%';4、查询没学过“叶平”老师课的同学的学号、姓名; Student.S#,Student.SnamefromStudentwhereS#notin(selectdistinct(SC.S#)fromSC,Course,TeacherwhereSC.C#=Course.C#andTeacher.T#=Course.T#andTeacher.Tname='叶平');5、查询学过“001”并且也学过编号“002”课程的同学的学号、姓名;selectdistinct(a.s),a.snamefrom(selectstudent.s,student.sstudent,scwherestudent.s=sc.s andsc.c=2)a,(selectstudent.s,studfromstudent,scwherestudent.s=sc.sandsc.c=1)bwhere a.s=b.s6、查询学过“叶平”老师所教的所有课的同学的学号、姓名;select*from(selectsc.c,student.s,student.sname,student.sage,student.ssexfromscleftjoinstudentonsc.s=student.s)a,(selectcourse.c,teacher.tnamefromteacherleftjoincourseoncourse.t=teacher.tandteacher.tname!='叶平')dwherea.c=d.c;7、查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名;selectdistinct(a.s),a.snamefrom(selectstudent.s,student.sname,sc.scorefromstudent,scwherestudent.s=sc.sandsc.c=2)a,(selectstudent.s,student.sname,sc.scorefromstudent,scwherestudent.s=sc.sandsc.c=1)bwherea.s=b.sanda.score>b.score;8、查询所有课程成绩小于60分的同学的学号、姓名;selectS#,SnamefromStudentwhereS#notin(selectStudent.S#fromStudent,SCwhereS.S#=SC.S#andscore>60);9、查询没有学全所有课的同学的学号、姓名;selectStudent.S#,Student.SnamefromStudent,SCwhereStudent.S#=SC.S#groupbyStudent.S#,Student.Snamehavingcount(C#)<(selectcount(C#)fromCourse);10、查询至少有一门课与学号为“1001”的同学所学相同的同学的学号和姓名; selectS#,SnamefromStudent,SCwhereStudent.S#=SC.S#andC#inselectC#fromSCwhereS#='1001';11、查询至少学过学号为“001”同学所有一门课的其他同学学号和姓名;selectb.s,b.snamefrom(selects,sname,count(c)cfrom(selectdistinctSC.S,Sname,sc.c,sc.scorefromStudent,SCwhereStudent.S=SC.Sandcin(selectCfromSCwhereS='201201'))agroupbya.s)bwhe