实验六答案数据库综合查询【骄阳教学】

上传人:8** 文档编号:119585720 上传时间:2022-07-15 格式:DOC 页数:4 大小:69.50KB
收藏 版权申诉 举报 下载
实验六答案数据库综合查询【骄阳教学】_第1页
第1页 / 共4页
实验六答案数据库综合查询【骄阳教学】_第2页
第2页 / 共4页
实验六答案数据库综合查询【骄阳教学】_第3页
第3页 / 共4页
资源描述:

《实验六答案数据库综合查询【骄阳教学】》由会员分享,可在线阅读,更多相关《实验六答案数据库综合查询【骄阳教学】(4页珍藏版)》请在装配图网上搜索。

1、1、查询以DB_开头,且倒数第三个字符为s的课程的详细情况select *from coursewhere cname like DB_%s_2、查询名字中第二个字为“阳”的学生姓名和学号及选修的课程号、课程名select student.sno ,student.sname ,o,cnamefrom student,course,scwhere sname like _阳%and student.sno=sc.sno and sc.Cno=o3、列出选修了数学或大学英语的学生学号、姓名、select student.sno,sname,sdept,sc.Cno,cname,gradefrom

2、 student,sc,coursewhere student.sno=sc.sno and sc.Cno=o and sc.sno in(select sc.sno from sc,course where (cname=大学英语or cname=数学)and sc.Cno=ogroup by sc.sno)select student.sno,sname,sdept,cno,gradefrom student,scwhere Cno in (select Cno from coursewhere cname=数学or cname=大学英语)and sc.sno=student.sno4、查

3、询缺少成绩的所有学生的详细情况;select *from student,scwhere Grade is null and student.sno=sc.sno5、查询与张力(假设姓名唯一)年龄不同的所有学生的信息;select *from studentwhere sage (select sagefrom studentwhere sname=张力)6、查询所选课程的平均成绩大于张力的平均成绩的学生学号、姓名及平均成绩select student.sno,sname,平均成绩=AVG(grade)from student ,scwhere student.sno=sc.snogroup

4、by student.sno,snamehaving AVG(Grade)(select AVG(Grade)from sc,student where sname=张力and student.sno=sc.sno)7、按照“学号,姓名,所在院系,已修学分”的顺序列出学生学分的获得情况。其中已修学分为考试已经及格的课程学分之和;select student.sno,sname,sdept,已修学分=SUM(ccredit)from student,sc,coursewhere Grade60and student.sno=sc.sno and sc.Cno=ogroup by student.

5、sno,sname,sdept8、列出只选修一门课程的学生的学号、姓名、院系及成绩select student.sno,sname,sdept,Cno,gradefrom student,scwhere student.sno=sc.sno and sc.sno in (select sno from sc group by sc.sno having COUNT(distinct Cno)=1)9、查找选修了至少一门和张力选修课程一样的学生的学号、姓名及课程号;select student.sno,sname,cnofrom student,scwhere student.sno=sc.sn

6、o and sc.sno in(select sc.sno from sc ,student where cno in(select cno from student,sc where sname=张力and student.sno=sc.sno) )10、只选修“数据库”和“数据结构”两门课程的学生的基本信息;select student.sno,snamefrom student,sc,coursewhere student.sno=sc.sno and sc.Cno=o and sc.sno in(select sc.sno from sc,course where (cname=数据库

7、or cname=数学)and sc.Cno=ogroup by sc.snohaving COUNT(*)=2)group by student.sno,snamehaving COUNT(*)=211、至少选修“数据库”或“数据结构”课程的学生的基本信息;只包括其中一门或两门:select student.sno,sname,sdept,sc.Cno,cname,gradefrom student,sc,coursewhere student.sno=sc.sno and sc.Cno=o and sc.sno in(select sc.sno from sc,course where (

8、cname=数据库or cname=数据结构)and sc.Cno=o )两门课全部包括:select student.sno,sname,sdept,sc.Cno,cname,gradefrom student,sc,coursewhere student.sno=sc.sno and sc.Cno=o and sc.sno in(select sc.sno from sc,course where (cname=数据库or cname=数据结构)and sc.Cno=ogroup by sc.snohaving COUNT(sc.Cno)=2)12、列出所有课程被选修的详细情况,包括课程号

9、、课程名、学号、姓名及成绩select o,cname,student.sno,sname,gradefrom student,sc,coursewhere student.sno=sc.sno and sc.Cno=oorder by o13、查询只被一名学生选修的课程的课程号、课程名select o,cnamefrom sc,coursewhere sc.Cno=ogroup by sc.Cno,cnamehaving COUNT(sc.sno)=114、检索所学课程包含学生张向东所学课程的学生学号、姓名至少包含一门张向东所选都的课程:select student.sno,sname,cn

10、o from student,scwhere student.sno=sc.sno and student.sno in (select sno from sc,course where sc.Cno=o and sc.Cno in (select cno from sc,student where sname=张向东and student.sno=sc.sno)包括张向东所选的全部课程:select *from studentwhere sno in (select sno from sc,course where sc.Cno=o and sc.Cno in (select cno fro

11、m sc,student where sname=张向东and student.sno=sc.sno)group by sc.snohaving COUNT(*)=(select COUNT(cno)from sc,student where sname=张向东and student.sno=sc.sno)15、使用嵌套查询列出选修了“数据结构”课程的学生学号和姓名select sno,snamefrom studentwhere sno in (select sno from sc,course where cname=数据结构and sc.Cno=o)16、使用嵌套查询查询其它系中年龄小于

12、CS系的某个学生的学生姓名、年龄和院系;select sname,sage,sdeptfrom studentwhere sageany(select sage from student where sdept=CS )and sdeptCS17、使用ANY、ALL 查询,列出其他院系中比CS系所有学生年龄小的学生select *from studentwhere sageall(select sage from student where sdept=CS)and sdeptCS;18、分别使用连接查询和嵌套查询,列出与张力在一个院系的学生的信息;select *from studentwh

13、ere sdept in(select sdept from student where sname=张力)19、使用集合查询列出CS系的学生以及性别为女的学生名单select *from studentwhere sdept=CSintersectselect *from studentwhere ssex=女20、使用集合查询列出CS系的学生与年龄不大于19岁的学生的交集、差集select *from studentwhere sdept=CSintersectselect *from studentwhere sage19select *from studentwhere sdept=CSexceptselect *from studentwhere sage1921、使用集合查询列出选修课程1的学生集合与选修课程2的学生集合的交集;select snofrom scwhere Cno=1intersectselect snofrom scwhere Cno=222、思考题:按照课程名顺序显示各个学生选修的课程(如200515001 数据库 数据结构 数学)select o,sno,cnamefrom sc,coursewhere sc.Cno=oorder by sno,sc.Cno asc4习题与教育

展开阅读全文
温馨提示:
1: 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
2: 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
3.本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
5. 装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
关于我们 - 网站声明 - 网站地图 - 资源地图 - 友情链接 - 网站客服 - 联系我们

copyright@ 2023-2025  zhuangpeitu.com 装配图网版权所有   联系电话:18123376007

备案号:ICP2024067431-1 川公网安备51140202000466号


本站为文档C2C交易模式,即用户上传的文档直接被用户下载,本站只是中间服务平台,本站所有文档下载所得的收益归上传人(含作者)所有。装配图网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对上载内容本身不做任何修改或编辑。若文档所含内容侵犯了您的版权或隐私,请立即通知装配图网,我们立即给予删除!