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

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

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

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、查询平均成绩大于60分的同学的学号和平均成绩;selectS#,avg(score)fromscgroupbyS#havingavg(score)>60;3、查询所有同学的学号、姓名、选课数、总成绩;selectStudent.S#,Student.Sname,count(SC.C#),sum(score)fromStudentleftOuterjoinSConStudent.S#=SC.S#groupbyStudent.S#,Sname4、查询姓“李”的老师的个数;selectcount(distinct(Tname))fromTeacherwhereTnamelike'李%';5、查询没学过“叶平”老师课的同学的学号、姓名;Student.S#,Student.SnamefromStudentwhereS#notin(selectdistinct(SC.S#)fromSC,Course,TeacherwhereSC.C#=Course.C#andTeacher.T#=Course.T#andTeacher.Tname='叶平');6、查询学过“001”并且也学过编号“002”课程的同学的学号、姓名;selectStudent.S#,Student.SnamefromStudent,SCwhereStudent.S#=SC.S#andSC.C#='001'andexists(Select*fromSCasSC_2whereSC_2.S#=SC.S#andSC_2.C#='002');7、查询学过“叶平”老师所教的所有课的同学的学号、姓名;selectS#,SnamefromStudentwhereS#in(selectS#fromSC,Course,TeacherwhereSC.C#=Course.C#andTeacher.T#=Course.T#andTeacher.Tname='叶平'groupbyS#havingcount(SC.C#)=(selectcount(C#)fromCourse,TeacherwhereTeacher.T#=Course.T#andTname='叶平'));8、查询课程编号“002”的成绩比课程编号“001”课程低的所有同学的学号、姓名;SelectS#,Snamefrom(selectStudent.S#,Student.Sname,score,(selectscorefromSCSC_2whereSC_2.S#=Student.S#andSC_2.C#='002')score2fromStudent,SCwhereStudent.S#=SC.S#andC#='001')S_2wherescore2<score;9、查询所有课程成绩小于60分的同学的学号、姓名;selectS#,SnamefromStudentwhereS#notin(selectStudent.S#fromStudent,SCwhereS.S#=SC.S#andscore>60);10、查询没有学全所有课的同学的学号、姓名;selectStudent.S#,Student.SnamefromStudent,SCwhereStudent.S#=SC.S#groupbyStudent.S#,Student.Snamehavingcount(C#)<(selectcount(C#)fromCourse);11、查询至少有一门课与学号为“1001”的同学所学相同的同学的学号和姓名;selectS#,SnamefromStudent,SCwhereStudent.S#=SC.S#andC#inselectC#fromSCwhereS#='1001';12、查询至少学过学号为“001”同学所有一门课的其他同学学号和姓名;selectdistinctSC.S#,SnamefromStudent,SCwhereStudent.S#=SC.S#andC#in(selectC#fromSCwhereS#='001');13、把“SC”表中“叶平”老师教的课的成绩都更改为此课程的平均成绩;updateSCsetscore=(selectavg(SC_2.sco