下载本文档
版权说明:本文档由用户提供并上传,收益归属内容提供方,若内容存在侵权,请进行举报或认领
文档简介
1、学习收藏数据库增删改查-查询信息系和计算机系的学生,并按学生所在系和学号排序 selectsno,sname,Sdeptfrom Student where Sdept='CS' OR Sdept='IS' order by Sdept, sno ASC-查询学生表中最小的年龄。 selectMIN (sagefrom student -查询课程名中包含 “数据 ”的课程名。 select cno ,cnamefrom course where Cname like '%数据 %'-查询先行课程为空值的课程号、课程名及学分 selectcno,c
2、name,ccredit from Course where Cpno is null-查询李勇选修的数据库课程的成绩 selectgradefrom SC where Sno =(selectSno from Student where Sname='李勇'and Cno =(select Cno from Course where cname='数据库'-查询平均成绩分以上的学生的学号 select distinct sno from SCscx where (select AVG (Grade from SCscy where scy.sno=scx.Sn
3、o >85-求计算机系没有选修数据库课程的学生姓名select snamefrom Studentwhere Sno not in (selectSno from SCwhere Cno in (selectCno from Coursewhere Sname='数据库' and Sdept='IS'-求至少选修了学号为 S1 所选修的全部课程的学生学号select distinct sno from SCscxwherenot exists (select * from SCscywhere scy.Sno='20021522'and n
4、ot exists(select* from scscz wherescz.sno=scx.snoandscy.Cno=scz.Cno-求各系的系的学生人数的,并将结果按学生人数的降序排序 selectSdept,COUNT(snofrom Studentgroup by Sdeptorder by Sdept ASC-查询选修了数学课程并且成绩高于该门课程平均分的学生学号和成绩 selectsno, gradefrom SCscxwhere Grade >=(selectAVG (Gradefrom SCscywhere Cno =(selectCno from Coursewhere
5、 Cname='数学' and Cno =(selectCno from Coursewhere Cname='数学 '/* 将学习了数据库课程的学生成绩加分。 */ updateSC setgrade=grade+5 where Cno in (selectCno from SC where Cno=(select Cno from Course where Cname='数据库' select* from SC/* 将计算机系学习了号课程的学生成绩置。 */ updateSCsetGrade=0where Sno in ( selectsc.
6、Sno from Student,SCwhere Cno ='2' andSdept='CS' select* from SC/* 将李勇的数据库成绩改为。 */ updateSCsetGrade=85where Sno=(select Sno from Studentwhere Sname='李勇' and Cno=(selectCno from Coursewhere Cname='数据库' select* from SC/* 将选修了号课程且成绩为空的选课记录删除。 */ deletefrom SC where Cno=
7、39;2' and Grade is null select* from SC /* 从课程表中删除在选课表中没有选课记录的课程记录。 */ deletefrom Coursewhere Cno not in(selectcno from SCselect * from Course/* 删除计算机系学生选修了数据库课程的选课记录。 */ deletefrom SCwhere Sno in(select Sno from Student where Sdept='CS'and Cno =(selectCno from Coursewhere Cname='数据库
8、 ' select* from SC/* 求各系的系名及男女生人数并将结果保存到另一个表中。 */ createtable Dept_ssex_count(Sdeptchar(15,Ssexchar(2,Count1 smallintinsert into Dept_ssex_coun(tSdept,Ssex, Count1select Sdept,Ssex,count(Sno from studentgroup by Sdept,Ssex;select * from Dept_ssex_countselect * from student/* 将平均成绩分以上的学生的学号,选学的课程
9、数和平均成绩保存到另一个表中。 */ createtable abc(Sno char(10,Course_countsmallint,avge floatinsert into abc(Sno,course_coun,tavge selectSno,count(cno,avg(gradefrom scscx group by snohaving avg(grade>=80;select* from abcselect * from sc/* 创建一个视图,查询没有选修课程的学生学号、姓名和所在系, 并利用该视图查询所有没有选修课程的学生信息。 */ createview No_sc_s
10、tudentasselect sno,sname,ssex,sage,sdept from student wheresno not in(selectdistinct Snofrom SC select * from No_sc_student /* 创建一个给出学生的姓名、课程名和成绩的视图,并利用该 视图查询某个学生学习的课程名和成绩。 */createview sname_cname_gradeasselect sname,cname,grade from Student ,Course ,SCwhere Student.Sno=SC.Sno and SC.Cno =Course.Cn
11、oselect * from sname_cname_grade /*创建一个视图,求各门课程的课程号、选课人数、平均分、最高分 ,并利用该视图查询号课程的选课人数、平均分、最高分。 */ createview CCAMasselectcno,COUNT(snocount1,AVG(gradeavge,MAX (grademax1 from SC group by Cnoselect * from ccamselectcount1,avge,max1 from ccamwhere cno='1'/* 创建一个视图,求选修了号课程且成绩高于该门课程平均分的学生 学号和成绩。 */createview Cno_2(sno,GradeasselectSno,Gradefrom SCwhere Cno='2' and grade >(select AVG (Gradefrom SC where Cno='2' select * from Cno_2/* 将学生表的 selec
温馨提示
- 1. 本站所有资源如无特殊说明,都需要本地电脑安装OFFICE2007和PDF阅读器。图纸软件为CAD,CAXA,PROE,UG,SolidWorks等.压缩文件请下载最新的WinRAR软件解压。
- 2. 本站的文档不包含任何第三方提供的附件图纸等,如果需要附件,请联系上传者。文件的所有权益归上传用户所有。
- 3. 本站RAR压缩包中若带图纸,网页内容里面会有图纸预览,若没有图纸预览就没有图纸。
- 4. 未经权益所有人同意不得将文件中的内容挪作商业或盈利用途。
- 5. 人人文库网仅提供信息存储空间,仅对用户上传内容的表现方式做保护处理,对用户上传分享的文档内容本身不做任何修改或编辑,并不能对任何下载内容负责。
- 6. 下载文件中如有侵权或不适当内容,请与我们联系,我们立即纠正。
- 7. 本站不保证下载资源的准确性、安全性和完整性, 同时也不承担用户因使用这些下载资源对自己和他人造成任何形式的伤害或损失。
最新文档
- 2025年社区团购产地直采与五年竞争策略报告
- 2025年新星市红星一场国有资产运营管理有限责任公司市场化公开招聘工作人员的备考题库含答案详解
- 2025年南昌市劳动保障事务代理中心招聘6名项目外包服务人员备考题库及答案详解一套
- 蓝色极简渐变弥散几何形状总结汇报述职报告模板
- 2025年柳州市鱼峰区花岭社区卫生服务中心招聘编外合同制工作人员备考题库及答案详解一套
- 海南省屯昌县2025年公开招聘县属国有企业领导人员备考题库(第1号)带答案详解
- 2025年成都大学附属小学公开招聘教师备考题库及完整答案详解1套
- 2025年国盛证券股份有限公司校园招聘41人备考题库及参考答案详解1套
- 2025年厦门市集美区后溪镇二农社区职业经理人招聘备考题库及答案详解1套
- 2026年威海市青少年宫公开招聘事业单位工作人员备考题库及1套完整答案详解
- 刑法学知到智慧树章节测试课后答案2024年秋上海财经大学
- 2025届河北省石家庄市普通高中学校毕业年级教学质量摸底检测英语试卷(含答案解析)
- 老年护理专科护士竞聘案例
- 伟大的《红楼梦》智慧树知到期末考试答案章节答案2024年北京大学
- AQ2059-2016 磷石膏库安全技术规程
- 喷涂车间操作工安全操作规程模版(三篇)
- 节水型小区总结汇报
- 2023中华护理学会团体标准-老年人误吸的预防
- 一年级数学重叠问题练习题
- 事业单位专业技术人员岗位工资标准表
- Android图形图像教学课件
评论
0/150
提交评论