




免费预览已结束,剩余5页可下载查看
下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
ACCESS中SQL专项训练题(二)(一)数据源情况:以下各题操作表结构如下:Student(学生表)字段名字段类型说明sno文本型学号,不能存在相同的sname文本型姓名,非空sex文本型性别,只能“男”或“女”dept文本型系别,包括这几个:信息系,计算机科学系,数学系,管理系,中文系,外语系,法学系birth日期/时间型出生日期age数值型年龄,在0100之间cs(成绩表):字段名字段类型说明Sno文本型学号Cno文本型课程号Cj数值型成绩, 只能在0100之间,可以不输入值course(课程表)字段名字段类型说明cno文本型课程号, 不能有重复的Cname文本型课程名,非空Cval数值型学分(二)针对学生课程数据库查询(1) 查询全体学生的学号与姓名。Select sno,sname from student(2) 查询全体学生的姓名、学号、所在系,并用别名显示出结果。Select sname as 姓名,sno as 学号,dept as 所在地 from student(3) 查询全体学生的详细记录。select * from student(4) 查全体学生的姓名及其出生年份。select sname,birth from student(5) 查询学校中有哪些系。select distinct dept from student(6) 查询选修了课程的学生学号。select sno from cs where cno is not null(7) 查询所有年龄在20岁以下的学生姓名及其年龄。select sname,age from student where age 20(8) 查询年龄在2023岁(包括20岁和23岁)之间的学生的姓名、系别和年龄。select sname,dept,age from student where age between 20 and 23(9) 查询年龄不在2023岁之间的学生姓名、系别和年龄。select sname,dept,age from student where age23(10) 查询信息系、数学系和计算机科学系生的姓名和性别。select sname,sex from student where dept=信息系 or dept=数学系 or dept=计算机科学系(11) 查询既不是信息系、数学系,也不是计算机科学系的学生的姓名和性别。select sname,sex from student where dept!=信息系 and dept!=数学系 and dept!=计算机科学系(12) 查询所有姓刘学生的姓名、学号和性别。select sname,sno,sex from student where sname like(刘%)(13) 查询学号为2009011的学生的详细情况。(具体的学号值根据表中数据确定)select * from student where sno=5(14) 查询姓“欧阳”且全名为三个汉字的学生姓名select sname from student where sname like(欧阳_)(15) 查询名字中第2个字为“晨”字的学生的姓名和学号select sname,sno from student where sname like(_晨)(16) 查询所有不姓刘的学生姓名。select sname,sno from student where sname not like(刘%)(17) 查询sql课程的课程号和学分。select cno from course where cname=sql(18) 查询以DB_开头,且倒数第3个字符为 i的课程的详细情况。select * from course where cname like(DB_%i_)(19) 查询缺少成绩的学生的学号和相应的课程号。select sno,cno from cs where cj is null(20) 查所有有成绩的学生学号和课程号。select sno,cno from cs where cj is not null(21) 查询计算机系年龄在20岁以下的学生姓名。select sname from student where age 3(32) 查询有3门以上课程是90分以上的学生的学号及(90分以上的)课程数。select sno, count(cno) as 课程数 from cs where cj90 group by sno having count(cno)=3(33) 查询学生2006011选修课程的总学分。select sum(course) from course,cs where o=cs.sno and cs.sno=2006011(34) 查询每个学生选修课程的总学分。select sno,sum(cj)from cs,coursewhere o=ogroup by snounionselect sno, 0 from studentwhere sno not in (select sno from cs)(35) 查询每个学生及其选修课程的情况。select cs.sno,course.* from cs,course where o=o(36) 查询选修2号课程且成绩在90分以上的所有学生的学号、姓名select sno,sname from student where sno=(select sno from cs where cno=2 and cj90)(37) 查询每个学生的学号、姓名、选修的课程名及成绩。select student.sno,sname,course.course,cs.cj from student,course,cs where student.sno=cs.sno and o=o(38) 查询与“刘晨”在同一个系学习的学生(分别用嵌套查询和连接查询)-嵌套查询select * from student where dept in(select dept from student where sname=刘晨)-连接查询select stu1.* from student as stu1,student as stu2 where stu1.dept=stu2.dept and stu2.sname=刘晨-exists查询select * from student s1 where exists(select * from student s2 where s1.dept=s2.dept ands2.sname=刘晨)(39) 查询选修了课程名为“信息系统”的学生学号和姓名select sno,sname from student where sno in(select sno from cs where cno in(select cno from course where cname=信息系统)(40) 查询其他系中比信息系任意一个(其中某一个)学生年龄小的学生姓名和年龄select sname,age from student where age any(select age from student where dept=信息系)(41) 查询其他系中比信息系所有学生年龄都小的学生姓名及年龄。分别用ALL谓词和集函数-用ALLselect sname,age from student where age all(select age from student where dept=信息系)-聚合函数select sname,age from student where age (select min(age) from student where dept=信息系)(42) 查询所有选修了1号课程的学生姓名。(分别用嵌套查询和连查询)-嵌套查询select sname from student where sno in(select sno from cs where cno=1)-连接查询select sname from student,cs where student.sno=cs.sno and o=1(43) 查询没有选修1号课程的学生姓名。select sname from student where sno in(select sno from cs where cno!=1)(44) 查询选修了全部课程的学生姓名。select sname from student where not exists(select * from course where not exists (select * from cs where cs.sno=student.sno o=o)(45) 查询至少选修了学生95002选修的全部课程的学生号码。select distinct sno from sc scx where not exists(select * from cs scy where scy.sno=95002 and not exists(select * from sc scz where scz.sno=scx.sno and o=o)(46) 查询计算机科学系的学生及年龄不大于19岁的学生的信息。select * from student where dept=计算机科学系 or age19(47) 查询选修了课程1或者选修了课程2的学生的信息。select student.* from student,cs where student.sno = cs.sno and (o=1 or o=2)(48) 查询计算机科学系中年龄不大于19岁的学生的信息。select * from student where age19(51) 通过查询求学号为1学生的总分和平均分。select sum(cj) as 总分,avg(cj)平均分 from cs where sno=1(52) 求出每个系的学生数量select dept,
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 新解读《GB-T 30718-2014压缩氢气车辆加注连接装置》
- 人教版八年级英语上册期末必考作文范文归纳
- 人教PEP版六年级英语上册全册教案
- 课件-低碳工地生态文明-浅谈如何做好施工现场的环境保护与文明施工管理
- 重卡配件知识入门培训班课件
- 《英语听力1》课程介绍与教学大纲
- 社会科学研究方法 课件 第五章 抽样
- 老年人用品课件
- 老年人拐杖培训课件
- 酿酒知识培训课件
- 护士医护人员职业安全防护培训
- 六年级家长会课件
- 2025年党建党史知识竞赛测试题库及答案
- 2025年教科版新教材科学二年级上册教学计划(含进度表)
- GB/T 45859-2025耐磨铸铁分类
- 临床基于ERAS理念下医护患一体化疼痛管理实践探索
- 2025年河北交警三力测试题及答案
- 2025贵州贵阳供销集团有限公司招聘笔试历年参考题库附带答案详解
- 人教版(2024)新教材三年级数学上册课件 1.2 观察物体(2)课件
- 颈椎骨折脊髓损伤的护理
- 华为海外税务管理办法
评论
0/150
提交评论