欢迎来到天天文库
浏览记录
ID:40641089
大小:1.23 MB
页数:9页
时间:2019-08-05
《实验03-利用查询分析器查询(二)》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库。
1、实验三利用查询分析器查询(二)【实验目的】1.学会利用查询分析器进行复杂查询和操作;【实验内容】1.使用样本(实验一)中的数据库。2.学会TRANSACT-SQL语言的使用。3.实行如下要求的查询和操作:①求出有一门课成绩在85分上的学生的学号、姓名SELECTsno,snameFROMstudentWHEREsnoIN(SELECTsnoFROMscWHEgrade>85)②求出各门课程成绩均在85分以上学生的学号、姓名selectsno,snamefromstudentwheresnoin(selectsno
2、fromscgroupbysnohavingmin(grade)>85)9①查询没有选修“030303”号课程的学生姓名和年龄selectsname,agefromstudentwherenotexists(select*fromscwherecno='030303')②查询各门课程取得最高成绩的学生姓名和成绩selectsname,gradefromstudent,scywheregrade=(selectmax(grade)fromscwherecno=y.cno)andstudent.sno=y.sno9①
3、检索学习了课程“操作系统”或“数据库系统原理”或“编译原理”其中一门课的学生学号。selectsnofromstudentwheresnoin(selectsnofromscwherecnoin(selectcnofromcoursewherecname='操作系统'orcname='数据库系统原理'orcname='编译原理'))9①检索已经学习课程“操作系统”和“数据库系统原理”二门课的学生学号。selectsnofromstudentwheresnoin(selectsnofromscwherecnoin(
4、selectcnofromcoursewherecname='操作系统'))andsnoin(selectsnofromscwherecnoin(selectcnofromcoursewherecname='数据库系统原理'))9①查询至少选修了学生130803101选修的全部课程的学生学号详见课本P111selectdistinctsnofromscxwherenotexists(select*fromscywherey.sno='130803101'andnotexists(select*fromsczwhe
5、rez.sno=x.snoandz.cno=y.cno))9①列出所有同学的姓名、课程名和成绩selectsname,cname,gradefromstudent,sc,coursewherestudent.sno=sc.snoandsc.cno=course.cno9①查询与学生‘王丽’在同一班级学习的学生(用“IN”谓词表示)selectsnofromstudentwhereclsin(selectclsfromstudentwheresname='李梅梅')②列出李伟同学所有未选修课程的课程号和课程名(用存
6、在量词表示)selectcno,cnamefromcoursewherenotexists(selectcnofromscwheresnoin(selectsnofromstudentwheresname='李伟'))9①列出成绩比该课程平均成绩低的同学的成绩表selectsno,cno,gradefromscxwheregrade<(selectavg(grade)fromscwherecno=x.cno)②列出所有选修‘操作系统’课程的‘男’同学的成绩表selectsno,cno,gradefromscxwh
7、eresnoin(selectsnofromscwherecno=(selectcnofromcoursewherecname='操作系统'))andsnoin(selectsnofromstudentwheresex='男')9【实验步骤】(要求自己填写详细的实验步骤)【实验体会及存在问题】(要求自己填写)9
此文档下载收益归作者所有