???????? ????? student(s#??sname??sage??ssex)????? course??c#??cname??T#???γ?? sc(s#??c#??score)????? Teacher(T#??tname)????? 1.???001?γ??002?γ??????????????????? select sc1.s# from sc sc1 join sc sc2 on sc1.s# = sc2.s
?????????
????student(s#??sname??sage??ssex)?????
????course??c#??cname??T#???γ??
????sc(s#??c#??score)?????
????Teacher(T#??tname)?????
????1.???001?γ??002?γ???????????????????
????select sc1.s#
????from sc sc1 join sc sc2 on sc1.s# = sc2.s#
????where sc1.c# = ‘001’ and sc2.c# = ‘002’ and sc1.score > sc2.score
????2.?????????????60???????????????????
????select s#?? avg(score) from sc group by s# having avg(score)>60;
????3.??????????????????????????????????
????select student.s#??student.name ??count(sc.c#) ??sum(sc.score)
????from student left join sc on student.s# = sc.s#
?????????????????????????????????????????Ч?????
????4.?????????????????
????select count(T#) from Teacher where tname like “??%”
??????????????? %?????????????_????????????????[……]????????????????е????????? [^……]?????????????????е???????
????5.???????????????ε?????????????
????select studet.s# student.sname
????from student
????where s# not in (select distinct(sc.s#) from sc?? course?? teacher where sc.c# = course.c# and teacher.t# = course.t# and teacher.tname = “??”)??
???????????? + ????
????6.??????001??002?γ??????????????
????select student.s3 student .sname
????from student join course on student.s# = course.s#
????where(course.c# = ‘001’ union course.c# = ‘002’);
????7.????????????ε???????????????
????select student.s# student.sname
????from student
????where s# in(select distinct(sc.s#) from sc course teacher where sc.c# = course.c# and teacher.t# = course.t# and teacher.tnmae = “??”)
???????distinct???????
????8.???002?????001?????????????????
????select student.s# student .name
????from student where student.s# in(select sc1.s# from sc sc1 join sc sc2 on sc1.s# = sc2.s# where s1.c# = 001 and s2.c# = 002 and sc1.score> sc2.score);
????9.??????пγ???С??60?????????????????
????select student.s# student.sname from student join sc on student.s# = sc.s#
????where sc.score > 60;
????10.???????? ???пε???????????????
????select student.s# student.sname from student??sc
????where student.s# = sc.s# group by student.s#??student.sname having count(c#) < (select count(c#)from course);
????11.????????????γ??????1001??????????????????????????
????select student.s# ??student.sname from student join sc
????where student.s# = sc.s# and c# in select c# from sc where s# = ‘1001’
????12.??????????????001?????????ε???????????????????
????select distinct student.s#??student??sname from
????SC join student on SC.s# = student.s#
????where c# in(select c# from sc where s#=’001’);