- 1、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。。
- 2、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 3、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
- 4、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
- 5、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们。
- 6、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
- 7、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
北邮大三数据库实验的三数据查询实验
实验三 数据查询实验
实验目的
通过对实验二中建立的学生数据库关系表和视图的各种查询的操作,加深对SQL查询语言的了解,掌握相关查询语句的语法和使用方法。
实验步骤
1、在简单查询实验中,在sql语句完成以下查询操作:
(1)查询“数据库原理”课程的学分;
select credit
from course
where course_name=数据库原理
(2)查询选修了课程编号为“C01”的学生的学号和成绩,并将成绩按降序输出;
select student_id,score
from sc
where course_id=C01
order by score desc
一共25条查询结果
查询学号为“31401”的学生选修的课程编号和成绩;
select course_id,score
from sc
where student_id=31401
一共3条查询结果
(4)查询选修了课程编号为“C01”且成绩高于85分的学生的学号和成绩。
select student_id ,score
from sc
where course_id=C01 and score 85
一共5条查询结果
2、在多表连接的查询实验中,在SQL SERVER提供的交互式语言环境下用Transact SQL语句完成以下查询操作:
(1)查询选修了课程编号为“C01”且成绩高于85分的学生的学号、姓名和成绩;
select sc.student_id ,student_name,score
from sc,student
where sc.course_id =C01
and sc.student_id =student.student_id
and sc.score 85
一共5条查询结果
查询所有学生的学号、姓名、选修的课程名称和成绩;
select sc.student_id,student_name,course_name,score
from sc,student,course
where sc.student_id =student.student_id
and sc.course_id =course.course_id
一共142条查询结果
3、在复杂查询实验中,用 SQL语句完成以下查询操作:
(1)查询至少选修了三门课程的学生的学号和姓名;
select sc.student_id,student.student_name,COUNT(sc.course_id )
from sc,student
where sc.student_id =student.student_id
group by sc.student_id,student_name
having COUNT(sc.course_id )=3
一共39条查询结果
查询所有学生的学号和他选修课程的最高成绩,要求他的选修课程中没有成绩为空的。
select sc .student_id,student_name,max(score ) as max_score
from sc,student
where sc.student_id in
((select sc .student_id
from sc,student
where sc.student_id =student.student_id)
except
(select sc .student_id
from sc,student
where sc.student_id =student.student_id and score is NULL))
and sc.student_id =student.student_id
group by sc .student_id,student_name
一共52条查询结果,成绩为NULL的30401和30402号同学有成绩为空,不在查询结果中
在嵌套查询实验中,在SQLServer提供的交互式语言环境下用iSQL语句完成以下查询操作,要求写嵌套查询语句:
查询选修了数据库原理的学生的学号和姓名;
select student_id ,student_name
from student
where student_id in
(select student_id
from sc,course
where sc.course_id =course.course_id
and course_name=数据库原理
)
select student_id ,student_name
from student
where st
您可能关注的文档
最近下载
- 专题04 阅读理解(含答案析)(中考英语考试题分项汇编(四川专用)).docx VIP
- 2025河北高速燕赵驿行集团有限公司社会招聘笔试参考题库附答案解析.docx VIP
- 雨课堂 科研伦理与学术规范-期末考试答案及各章节答案.docx VIP
- 2025河北高速燕赵驿行集团有限公司社会招聘笔试备考试题及答案解析.docx VIP
- 美的集团的ESG报告:2022ESG Report.pdf VIP
- 最简单的个人股权转让协议5篇.docx VIP
- 《全国医疗服务价格项目规范》(2021版).docx VIP
- 华南理工大学《信号与系统》历年多套期末考试试卷(含答案).pdf VIP
- 夏季防暑降温指南预防中暑健康教育讲座主题班会PPT课件.pptx VIP
- 2025年广东省春季高考英语语法填空专项复习试题三(含答案解析).pdf VIP
原创力文档


文档评论(0)