




版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、数据库基础与应用中SQL语句答案 检索 王海”同学不学的课程的课程名检索至少选修了 程军”老师所授全部课程的学生的学号和姓名检索只选修了 C语言”的女学生的学号和姓名 检索至少选修了 王海”同学所选修的全部课程的学生的学号和姓 名检索所有选修C语言”的同学的平均年龄检索至少有两个同学选修的课程的课程名 检索每门课程的选修人数和平均分数检索选修了全部课程的学生的学号和姓名检索至少选修了 程军”老师所授全部课程的学生的学号和姓名 检索至少选修了两门课程的学生的学号和姓名检索同时选修了 C语言”和 编译原理”的同学的学号和姓名检索至少选修了 王海”同学所选修的全部课程的学生的学号和姓 名 检索没有选
2、修任何课程的学生的学号和姓名检索所有课程的成绩都在分以上的同学的学号和姓名检索全部 女”同学都选修的课程的课程名 检索有 女”同学选修的课程的课程号和课程名检索每门课程的选修人数和最高分检索全部 男”同学都选修的课程的课程名 检索所有课程的平均分在分以上的同学的学号和姓名检索每个同学的选课门数及平均分、最高分、最低分检索选修了全部课程的学生的学号和姓名 检索选课门数最多的学生的学号和姓名检索各科成绩均大于等于该科平均成绩的学生的学号和姓名检索全部 男”同学都选修的课程的课程名 检索选修人数最多的课程的课程号和课程名检索只选修了C语言”的学生的学号和姓名检索至少选修了王海”同学所选修的全部课程的
3、学生的学号和姓名 检索没有选修数据库原理”的学生的学号和姓名检索只选修了数据库原理”的学生的学号和姓名检索选修了全部课程的学生的学号和姓名(11) 检索 女”同学都没有选修的课程的课程名检索只选修了C语言”的学生的学号和姓名检索至少选修了王海”同学所选修的全部课程的学生的学号和姓名(12) 检索至少选修了三门课程的同学的学号检索选修了全部课程的学生的学号和姓名检索每门课程的选修人数和最高分(13) 检索至少有两门课程在分以上的学生的学号检索没有选修课程的学生的学号和姓名检索至少选修了程军”老师所授全部课程的学生的学号和姓名圍 检索全部课程都及格的学生的学号和姓名检索选修人数最多的课程的课程号和
4、课程名检索只选修了C语言”的学生的学号和姓名(15) 检索没有选修C语言”的学生的学号和姓名检索每个同学的选课门数及平均分、最高分、最低分检索选修了全部课程的学生的学号和姓名(16) 统计每门课程的选修人数和平均分检索所有课程的成绩都在分以上的同学的学号和姓名检索全部 女”同学都选修的课程的课程名(17) 检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名检索至少选修了两门课程的学生的学号和姓名检索同时选修了C语言”和编译原理”的同学的学号和姓名(18) 检索所有课程的平均分在分以上的同学的学号和姓名检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名检索选修了全部课程的学生
5、的学号和姓名(19) 检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名检索至少选修了程军”老师所授全部课程的学生的学号和姓名检索只选修了C语言”的女学生的学号和姓名(20) 检索至少选修了王海”同学所选修的全部课程的学生的学号和姓检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名检索至少有两个同学选修的课程的课程名(21) 检索选课门数最多的学生的学号和姓名检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名检索至少选修了三门课程的同学的学号(22) 检索至少有两门课程在分以上的学生的学号检索每个同学的选课门数及平均分、最高分、最低分检索选修了全部课程的学生的学号
6、和姓名(23) 检索只选修了数据库原理”的学生的学号和姓名检索选修了全部课程的学生的学号和姓名检索 男”同学和 女”同学都选修的课程的课程号和课程名(24) 检索至少有两门课程在分以上的学生的学号检索每个同学的选课门数及平均分、最高分、最低分检索选修了全部课程的学生的学号和姓名(25) 检索选课门数最多的学生的学号和姓名检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名检索至少选修了三门课程的同学的学号(26) 检索只选修了 C语言”的学生的学号和姓名检索至少选修了 王海”同学所选修的全部课程的学生的学号和姓检索只有 男”学生选修的课程的课程号和课程名(27) 检索只选修了数据库原理
7、”的学生的学号和姓名检索选修了全部课程的学生的学号和姓名检索 女”同学都没有选修的课程的课程名(28) 检索至少选修了 程军”老师所授全部课程的学生的学号和姓 名检索只选修了 C语言”的女学生的学号和姓名检索至少选修了 王海”同学所选修的全部课程的学生的学号和姓 名select* from sselect* from cselect* from sc1检索 王海”同学不学的课程的课程名a selectcnamefrom c where c# not in (select c# from sc where s#in (selects#from swheresname=王海)b selectcna
8、mefrom c where not exists(select* from scwherescc#=c.c#andsc.s#in (selects#from swheresname=王海)2检索至少选修了程军”老师所授全部课程的学生的学号和姓名selects#,snamefrom s where not exists(select* from c where teacher=程军andnot exists(select* from sc where s.s#=sc.s# andc.c#二see#)3检索只选修了 C语言”的女学生的学号和姓名selects#,snamefrom s where
9、 sex=女ands#in(selects# from sc where c# in (selectc#from c wherecname=C语言)and s# not in (selects# from sc where c# in(selectc#from c where cname!=C语言)(二)1检索至少选修了 王海”同学所选修的全部课程的学生的学号和姓名selects#,snamefrom s where not exists(select* from c where c#in (selectc#from sc where s#in (selects#from swheresnam
10、e=王海)andnotexists(select* from sc where c.c#=sc.c# and scs#=s.s#)2检索所有选修C语言”的同学的平均年龄a selectavg(age)as 平均年龄 from s where not exists ( select* from c where cname=C语言and not exists ( select* from sc where s.s#=sc.s#and c.c#=sc.c#) b selectavg(age)as 平均年龄 from s where s#in (selects# from sc where c# in
11、 (selectc# from c where cname=C语言)3检索至少有两个同学选修的课程的课程名select c.c#,cnamefrom sjoin scjoin con c.c#=sc.c#on s.s#=scs#group by c.c#,cnamehaving count(*) =21检索每门课程的选修人数和平均分数selectc.c#,count(*) as 人数,avg(gradq as 平均分数 froms,c,sc where s.s#=scs#a nd c.c#=sc.c#group by c.c#2检索选修了全部课程的学生的学号和姓名selects#,snamef
12、rom s where not exists(select* from c where not exists (select* from sc where s.s#=sc.s# andc.c#=scc#)3检索至少选修了程军”老师所授全部课程的学生的学号和姓名selects#,snamefrom s where not exists (select* from c where cname=程军and not exists(select* from sc where s.s#=sc.s# andc.c#二see#)(四)1检索至少选修了两门课程的学生的学号和姓名selects.s站snameco
13、unt(*) as 课程数 from s,c,scwhere s.s#=sc.s# and c.c#=scc#group by s.s#,snamehaving count(*)= 22检索同时选修了 C语言”和 编译原理”的同学的学号和姓名selects#,snamefrom s where s# in(selects# from sc where c# in (selectc#from c wherecname=C语言)and s#in(selects#from sc where c# in (selectc#from c wherecname=编译原理)3检索至少选修了王海”同学所选修的
14、全部课程的学生的学号和姓名selects#,snamefrom s where not exists(select* from c where c#in (selectc#from sc where s#in ((五)1检索没有选修任何课程的学生的学号和姓名selects#,snamefrom swheres#notin (selects# from sc where c# in (selectc#from c)insert into s valueqS6;张军,男,22)2检索所有课程的成绩都在分以上的同学的学号和姓名selects#,snamefrom s where not exists
15、(select* from scwheres.s#=scs#andgrade85b selects#,snamefrom s where s# in(selects#from scgroup by s#having avg(grad85)2检索每个同学的选课门数及平均分、最高分、最低分selects#,count(*) as 选课门数,avg(gradas 平均分,max(gradeas 最高分,min(gradas 最低分from scgroup by s#3检索选修了全部课程的学生的学号和姓名selects站snamefrom s where not exists(select* from
16、 c where not exists(select* from scwheres.s#=scs#andc.c#二sc.c#)(八)1检索选课门数最多的学生的学号和姓名select top 1 with ties s.s#,snamefrom s,scwhere s.s#=sc.s#group by s.s#,snameorder by count(*) desc2检索各科成绩均大于等于该科平均成绩的学生的学号和姓名selects#,snamefrom s where not existssc.s#=s.s# and c.c#=sc.c# group by c#)(select* from s
17、c,c where grade= 32检索选修了全部课程的学生的学号和姓名select* from c where not exists(select* from scwheres.s#=scs#andc.c#二sc.c#)3检索每门课程的选修人数和最高分selectc.c#,count(*) as 选修人数,max(grade)as 最高分 from c,scwhere c.c#=sc.c#group by c.c#(十三)1检索至少有两门课程在分以上的学生的学号select s.s#from s,scwhere s.s#=sc.s# an dgrade60group by s.s#havi
18、ng count(*)= 22检索只选修了 C语言”的学生的学号和姓名selects站snamefrom s wheres#in(selects# from sc where c#i n(selectc# from c where cname=C语言)an ds# not in(selects# from sc where c#i n(selectc#from cwherecname!= C语言)3检索至少选修了王海”同学所选修的全部课程的学生的学号和姓selects#,snamefrom s where not exists(select* from c wherec# in (select
19、 c# from sc where s#in(selects#from swheresname=王海)andnot exists(select* from scwheres.s#=scs#andc.c#二sc.c#)(十四)1检索全部课程都及格的学生的学号和姓名selects站snamefrom s wheres#in(selects# from sc where s.s#=sc.s#group by s#having min(grad=60 )2检索选修人数最多的课程的课程号和课程名select top 1 with ties c.c#,cnamefrom c,scwhere c.c#=sc
20、.c#group by c.c#,cnameorder by count(*) desc3检索只选修了 C语言”的学生的学号和姓名selects站snamefrom s wheres#in(selects# from sc where c#i n(selectc# from c where cname=C语言)an ds# not in(selects# from sc where c#i n(selectc#from cwherecname!= C语言) (十五)1检索没有选修C语言”的学生的学号和姓名selects站snamefrom swheres#notin (selects# fro
21、m sc where c#i n(selectc# from c where cname=C语言)2检索每个同学的选课门数及平均分、最高分、最低分selects.s#,count(*) as 选课门数,avg(gradas 平均分, max(gradeas 最高分,min(gradas 最低分 from s,scwheres.s#=scs#group by s.s#3检索选修了全部课程的学生的学号和姓名selects站snamefrom s where not exists(select* from c where not exists(select* from scwheres.s#=scs
22、#andc.c#二sc.c#)(十六)1统计每门课程的选修人数和平均分selectc.c#,count(*)as 选修人数,avg(gradas 平均分 from c,sc where c.c#=sc.c#group by c.c#2检索所有课程的成绩都在分以上的同学的学号和姓名selects#,snamefrom s where not exists(select* from scwheres.s#=scs#andgrade=80)and s# in (selects# from scgroup by s#)3检索全部 女”同学都选修的课程的课程名select cnamefrom c whe
23、re notexists(select* from s wheresex=女 and not exists(select* from sc where s.s#=sc.s# and c.c#=sc.c#)(十七)1检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名selects站snamefrom s where not exists(select* from sc,c wheregrade= 23检索同时选修了 C语言”和 编译原理”的同学的学号和姓名selects#namefrom s wheres#in(selects# from sc where c#i n (selectc
24、# from c where cname=C语言)ands#in(selects#from sc where c#in (selectc# from c where cname=编译原理)(十八)1检索所有课程的平均分在分以上的同学的学号和姓名aselects.s#,snamefrom s,scwhere s.s#=sc.s#group by s.s#,snamehaving avg(grad85b selects#,snamefrom s where s# in(selects#from scgroup by s#having avg(grad85)2检索每门课程的成绩均高于该门课程平均成绩
25、的学生的学号和姓 名selects#,snamefrom s where not exists(select* from sc,c where grade(selectavg(grade) from sc wheresc.s#=s.s# and c.c#=sc.c# group by c#)3检索选修了全部课程的学生的学号和姓名selects#namefrom s where not exists(select* from c where not exists(select* from scwheres.s#=scs#andc.c#二sc.c#)(十九)1检索每门课程的成绩均高于该门课程平均成
26、绩的学生的学号和姓名selects#,snamefrom s where not exists(select* from sc,c where grade(selectavg(grade) from sc wheresc.s#=s.s# and c.c#=sc.c# group by c#)2检索至少选修了程军”老师所授全部课程的学生的学号和姓名selects站snamefrom s where not exists(select* from c where teache=程军and not exists(select* from scwheres.s#=scs#andc.c#=sc.c#)3
27、检索只选修了 C语言”的女学生的学号和姓名selects站snamefrom s wheresex=女 ands#in(selects# from sc where c#i n (selectc# from c where cname=C语言)an ds# notin (select s# from sc where c# in (select c# from c where cn ame !=C 语言)(二十)1检索至少选修了 王海”同学所选修的全部课程的学生的学号和姓selects#,snamefrom s where not exists(select* from c where c#i
28、n (selectc#from sc where s#in (selects# from s where sname=王海)and not exists(select* from sc where c.c#=sc.c# and scs#二s.s#)2检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名selects#,snamefrom s where not exists(select* from sc,c where grade=2(二十一)1检索选课门数最多的学生的学号和姓名where s.s#=sc.s#selecttop 1 with ties s.s#,snamefrom
29、s,scgroup by s.s#,snameorder by count(*) desc2检索每门课程的成绩均高于该门课程平均成绩的学生的学号和姓 名selects#,snamefrom s where not exists(select* from sc,c where grade= 3(二十二)1检索至少有两门课程在分以上的学生的学号select s.s#from s,scwhere s.s#=sc.s# an dgrade60group by s.s#having count(*)= 22检索每个同学的选课门数及平均分、最高分、最低分selects#,count(*) as 选课门数,
30、avg(gradas 平均分,max(gradas 最高分,min(gradas 最低分from scgroup by s#3检索选修了全部课程的学生的学号和姓名selects站snamefrom s where not exists(select* from c where not exists(select* from scwheres.s#=scs#andc.c#二sc.c#)(二十三)1检索只选修了 数据库原理”的学生的学号和姓名selects站snamefrom s wheres#in(selects# from sc where c#i n (selectc# from c whe
31、re cname=数据库原理)an ds# not in(selects# from sc where c#i n (selectc#from cwherecname!二数据库原理)2检索选修了全部课程的学生的学号和姓名selects站snamefrom s where not exists(select* from c where not exists(select* from scwheres.s#=scs#andc.c#二sc.c#)3检索 男”同学和 女”同学都选修的课程的课程号和课程名select c#,cnamefrom c where c# in(select c# from s
32、c where s#in (selects#from swheresex=男)andc#i n(selectc#from sc where s#i n (selects#from swheresex=女)(二十四)1检索至少有两门课程在分以上的学生的学号select s.s#from s,scwhere s.s#=sc.s# an dgrade60group by s.s#having count(*)= 22检索每个同学的选课门数及平均分、最高分、最低分selects#,count(*) as 选课门数,avg(gradas 平均分,max(gradeas 最高分,min(gradas 最低
33、分from scgroup by s#3检索选修了全部课程的学生的学号和姓名selects站snamefrom s where not exists(select* from c where not exists(select* from scwheres.s#=scs#andc.c#二sc.c#)(二十五)1检索选课门数最多的学生的学号和姓名select top 1 with ties s.s#,snamefrom s,scwhere s.s#=sc.s#group by s.s#,snameorder by count(*) desc 2检索每门课程的成绩均高于该门课程平均成绩的学生的学号
34、和姓 名selects#,snamefrom s where not exists(select* from sc,c where grade= 3(二十六)1检索只选修了 C语言”的学生的学号和姓名selects#,snamefrom s where s#in(selects# from sc where c# in (selectc#from c wherecname=C语言)and s# not in (selects# from sc where c# in(selectc#from c where cname!=C语言) 2检索至少选修了王海”同学所选修的全部课程的学生的学号和姓名selects#,snamefrom s where not exists(select* from c
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2026年中国大唐集团有限公司校园招聘考试模拟试题及答案解析
- 家用电器安全培训测试题及答案解析
- 2025年中考社会真题试卷及答案
- 建筑c1安全员题库及答案解析
- 咖啡店活动策划方案书模板
- 2025年全国“安全生产月”《安全知识》竞赛试题库(附答案)
- 2025江西文演数字文化产业有限公司招聘数字运营项目经理岗位1人考试参考试题及答案解析
- 2025医师事业单位试题及答案
- 2025年福建省泗华小学编外合同教师自主招聘备考考试题库附答案解析
- 2025年上海复旦大学附属浦东实验学校教师招聘模拟试卷及一套完整答案详解
- 2025年甘肃省天水市供热有限公司招聘12人考试历年参考题附答案详解
- 新版中华民族共同体概论课件第七讲华夷一体与中华民族空前繁荣(隋唐五代时期)-2025年版
- 急性淋巴细胞白血病
- 围墙装饰墙帽施工方案
- 燃气运营安全管理方案
- 企业安全生产费用预算表模板
- (正式版)DB44∕T 2697-2025 《岩土工程勘察安全技术标准》
- 畜牧兽医专业毕业论文豆
- 简易版关于做好县委巡察组巡视商务局期间信访稳定工作的应急预案
- 2025年中秋节知识竞赛题库及答案
- 2025装配钳工高级考试试题(含答案)
评论
0/150
提交评论