教学文库网 - 权威文档分享云平台
您的当前位置:首页 > 精品文档 > 高等教育 >

中南大学数据库课程设计题目答案(3)

来源:网络收集 时间:2026-07-23
导读: where score is not null and s.snum like ‘160111%’ and sc.snum=s.snum and left(snum,4)=mtrain.mnum group by s.snum, sname 10.分别统计各个专业必修、选修课程的门数,查询结果按专业排序; select major

where score is not null and s.snum like ‘160111%’ and sc.snum=s.snum and left(snum,4)=mtrain.mnum group by s.snum, sname

10.分别统计各个专业必修、选修课程的门数,查询结果按专业排序; select major 专业,ckind 课程性质,count(ckind)人数 from minf,mtrain

where minf.mnum=mtrain.mnum group by major,ckind order by major

11. 查询工商12级第三学期及以前所选课还没有成绩的学生学号、课程号、课程名及任课老师;

select snum 学号,c.cnum 课程号,cname 课程名,teacher 任课老师 from c,sc,mtrain

where score is null and sc.cnum=c.cnum

and mtrain.cnum=c.cnum and left(sc.snum,4)=mtrain.mnum and snum like'160112%' and cdate in ('一','二',’三’)

12. 查询工商12级选修课学分大于15分的学生学号及姓名 select snum 学号,sname 姓名,sum(credit) 选修学分 from mtrain,s

where left(snum,6)=160112 and left(snum,4)=mtrain.mnum group by snum,sname having sum(credit)>15

13.查询工商专业第五学期所有的选修课程; select cname 课程名 from c,mtrain

where cdate='五' and mnum='1601' and c.cnum=mtrain.cnum

14.查询工商11级学生选修课学分还没有达到25分的学生学号、姓名、专业及年级;

select s.snum 学号,sname 姓名,major 专业, substring(snum,5,2) 年级 from s,minf,mtrain

where s.mnum=minf.mnum and s.mnum=mtrain.mnum and s.snum like ‘160111%’ and s.snum in (select s.snum,sum(credit) from sc,mtrain where sc.cnum=mtrain.cnum and sum(credit)<25 andckind=’选’ group by s.snum having sum(credit)<25)

15. 按学期、按专业统计‘高强’老师所教授课程的学生的平均成绩,并把该查

询该结果以表的形式存储。

select AVG(score) 平均成绩,major 专业, cdate 学期 into 表15 from sc,mtrain,minf

where teacher=’高强’ and left(snum,4)=mtrain,mnum and mtrain.cnum=sc.cnum and minf,mnum=mtrain.mnum group by major,cdate

16. 查询工商12级第三学期各门课程不及格的学生,并用视图的形式存储不及格名单。

create view 不及格名单 AS

select s.snum 学号, sname 姓名,score 成绩 from sc,s,mtrain

where cdate=’三’ and s.snum like ‘160112%’ and left(s.snum,4)=mtrain.mnum and score<60 and mtrain.cnum=sc.cnum

17. 检索未选修“李中华”老师所授全部课程的学生学号; select distinct snum 学号 from sc where cnum not in

(select distinct cnum from sc where teacher =’李中华’) 问题:出现选修李中华部分课程的学生学号的多余项

解决:将cnum 改成snum,只要是选了李中华课的学号均不要 修正后如下:

select distinct snum 学号 from sc where snum not in

(select distinct snum from sc where teacher =’李中华’)

18. 统计商学院学生每门课程的平均成绩,要求列出课程名、平均成绩,并按平均成绩从高到低排列。

select cname 课程名, AVG(score) 平均成绩 from sc,c

where sc.cnum=c.cnum group by cname

order by AVG(score) desc

19. 统计每个老师所授每门课程的平均成绩,要求列出课程名、平均成绩,并按平均成绩从高到低排序。

select cname 课程名,teacher 教师, AVG(score) 平均成绩 from sc,c

where sc.cnum=c.cnum group by teacher,cname order by AVG(score) desc

20. 统计商学院12级学生第一学年的平均成绩及排名,检索结果送往另一个表存储,作为分专业的依据。

select snum 学号,AVG(score) 平均成绩 into 分专业依据 from sc

where snum like ‘160112%’ and cnum in

(select cnum from mtrain where cdate=’一’ or cdate=’二’) group by snum

order by AVG(score)

三、数据备份

用SQL SERVER 2000提供的备份功能对原始数据进行完全备份,并在做了第四部分数据更新后恢复数据库到更新前的状态。(备份方法见附录)

四、数据更新

1.在SC中删除选修课尚无成绩的选课元组;

delete from sc

where score is null and cnum in

(select cnum from mtrain where ckind=’选’)

2.将选修’ 刘兴’老师课程的女同学选课元组全部删除; delete from sc

where teacher=’刘兴’ and snum in

(select snum from s where sex=’女’) and cnum in

(select cnum from mtrain where ckind=’选’)

3.将工商12级学生’高等数学’课不及格的成绩全改为60分; update sc set score=’60’

where snum like ‘160112%’ and cnum in …… 此处隐藏:915字,全部文档内容请下载后查看。喜欢就下载吧 ……

中南大学数据库课程设计题目答案(3).doc 将本文的Word文档下载到电脑,方便复制、编辑、收藏和打印
本文链接:https://www.jiaowen.net/wendang/615584.html(转载请注明文章来源)
Copyright © 2020-2025 教文网 版权所有
声明 :本网站尊重并保护知识产权,根据《信息网络传播权保护条例》,如果我们转载的作品侵犯了您的权利,请在一个月内通知我们,我们会及时删除。
客服QQ:78024566 邮箱:78024566@qq.com
苏ICP备19068818号-2
Top
× 游客快捷下载通道(下载后可以自由复制和排版)
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
VIP包月下载
特价:29 元/月 原价:99元
低至 0.3 元/份 每月下载150
全站内容免费自由复制
注:下载文档有可能出现无法下载或内容有问题,请联系客服协助您处理。
× 常见问题(客服时间:周一到周五 9:30-18:00)