数据库第三章作业讲评.ppt





《数据库第三章作业讲评.ppt》由会员分享,可在线阅读,更多相关《数据库第三章作业讲评.ppt(12页珍藏版)》请在淘文阁 - 分享文档赚钱的网站上搜索。
1、第三章作业讲评1.对于下述三个关系:S(S#,Sn,Sa,Sex),C(C#,Cn,Cteacher,Credit),SC(S#,C#,Grade)使用SQL 语句表达下列查询请求:(1)检索学号比wang 同学大,而年龄比他小的学生姓名Select Sn from S where S#(select S#from S where S.Sn=wang)and SaS2.S#and S1.SaS2.Sa and S2.Sn=wangS1,S2 均为表别名第三章作业讲评(2)检索选修C4 课程的女生的平均年龄(3)检索年龄大于所有女同学年龄的男同学的姓名和年龄Select avg(Sa)from
2、S,SC where S.S#=SC.S#and C#=C4 and Sex=女Select avg(Sa)from S where S#in(select S#from SC where C#=C4)and Sex=女Select Sn,Sa from S where Saall(select Sa from S where Sex=女)and Sex=男第三章作业讲评(4)查询1984-1986 年出生的学生的学号、总平均成绩及已修学分数。(5)检索全部学生都选修的课程号和课程名Select S.S#,avg(Grade),sum(Credit)from S,C,SC where SC.C
3、#=C.C#and SC.S#=S.S#and Year(Getdate()-Sa between 1984 and 1986 group by S.S#Select C#,Cn from C where not exits(select*from S where not exists(select*from SC where SC.S#=S.S#and SC.C#=C.C#)第三章作业讲评(6)检索至少选修两门课程的学生姓名(7)检索王同学不学的课程的课程号和课程名Select Sn from S,SC where S.S#=SC.S#group by Sn having count(C#)
4、=2Select Sn from S where S#in(select S#from SC group by Sn having count(C#)=2)Select C#,Cn from C where C#not in(select C#from SC where S#in(Select S#from S where Sn=wang)Select C#,Cn from C where not exists(select*from SC,S where SC.C#=C.C#and SC.S#=S.S#,S.Sn=wang)(Select C#,Cn from C)except(select
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- 数据库 第三 作业 讲评

限制150内