- 1、本文档共11页,可阅读全部内容。
- 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
- 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载。
- 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
实验五SQL语言概要
实验
一、目的与要求
掌握;
二、实验准备
;
了解三、实验内容Select St_Name ,St_Sex, St_ID
From st_info
Where St_Name like 王%
查询全体学生的情况,查询结构按班级降序排列,同一班级再按学号升序,并将结果存入新表new中
select * into new
from st_info
order by Cl_Name desc,St_ID asc
对S_C_info表中选修了“体育”课的学生的平均成绩生成汇总行和明细行。(提示:用compute汇总计算)
Select c_no,score
From s_c_info
Where c_no
compute avg(score)
2.嵌套查询
查询其他班级中比“材料科学0601班”的学生年龄都大的学生姓名和年龄
Select St_Name ,Born_Date
from st_info
where Cl_Name!=材料科学0601班 and Born_Date(select Min(Born_Date) from st_info where Cl_Name=材料科学0601班)
用exists查询选修了“9710041”课程的学生姓名
select St_Name
from st_info
where exists (select * from s_c_info where c_no = 9710041 and st_id=st_info.St_ID )
用in查询找出没有选修“9710041”课程的学生的姓名和所在班级。
select St_Name,Cl_Name
from st_info
where st_ID not in (select st_id from s_c_info where c_no =9710041)
查询选修了学号为“2001050105”的学生所选全部课程的学生姓名。
select St_Name
from st_info where St_ID in
(select distinct St_ID from s_c_info where not exists
(select * from s_c_info where st_id=2001050105 and not exists
(select * from s_c_info where st_info.St_ID=s_c_info.st_id and c_no=any(select c_no from s_c_info where st_id=2001050105))))
3.连接综合查询及其他
查询每个学生所选课程的最高成绩,要求列出学号,姓名,课程编号和分数。
select st_info.St_ID, St_Name,C_info.c_no,score
from st_info inner join s_c_info on st_info.St_ID=s_c_info.st_id inner join C_info on s_c_info.c_no=C_info.c_no
where score=(select max(s_c_info.score)from s_c_info
where st_info.St_ID=s_c_info.st_id)
查询所有学生的总成绩,要求列出学号、姓名、总成绩,没有选修课程的学生总成绩为空。
select st_info.St_ID,St_Name,总成绩
from st_info
left outer join (select st_id,sum(score)as 总成绩 from s_c_info group by st_id)s_c_info on st_info.St_ID=s_c_info.st_id
查询“大学计算机基础”课程考试成绩前三名的学生姓名和成绩。
select st_info.St_ID,St_Name,score
from st_info
inner join s_c_info on st_info.St_ID=s_c_info.st_id
inner join C_info on s_c_info.c_no=C_info.c_no
and c_Name=大学计算机基础
将s_c_info中的score列的值转为等级制输出,即60分以下显示为“不及格”,60~69分显示“及格”,70~79分显示“中等”,80~81显示“良好”,90~100显示“优秀
您可能关注的文档
- 实验三BPSK传输系统实验概要.doc
- 实验中心制度汇编概要.doc
- 实验三基于simulink的通信系统仿真概要.doc
- 实验二、三层交换机配置概要.ppt
- 实验一运算放大器的基本应用概要.doc
- 实验二、产品发布概要.doc
- 实验五搜索引擎使用实验概要.doc
- 实验五异方差模型的检验概要.doc
- 实验二:线性表的链式表示和实现概要.doc
- 实验五清蛋糕的制作实验概要.ppt
- 新高考生物二轮复习讲练测第6讲 遗传的分子基础(检测) (原卷版).docx
- 新高考生物二轮复习讲练测第12讲 生物与环境(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第3讲 酶和ATP(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第9讲 神经调节与体液调节(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第11讲 植物生命活动的调节(讲练)(原卷版).docx
- 新高考生物二轮复习讲练测第8讲 生物的变异、育种与进化(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第5讲 细胞的分裂、分化、衰老和死亡(讲练)(原卷版).docx
- 新高考生物二轮复习讲练测第5讲 细胞的分裂、分化、衰老和死亡(检测)(原卷版).docx
- 新高考生物二轮复习讲练测第12讲 生物与环境(讲练)(原卷版).docx
- 新高考生物二轮复习讲练测第11讲 植物生命活动的调节(检测)(原卷版).docx
文档评论(0)