实验六:数据库综合查询-答案

实验六:数据库综合查询-答案

ID:38785390

大小:138.55 KB

页数:11页

时间:2019-06-19

实验六:数据库综合查询-答案_第1页
实验六:数据库综合查询-答案_第2页
实验六:数据库综合查询-答案_第3页
实验六:数据库综合查询-答案_第4页
实验六:数据库综合查询-答案_第5页
资源描述:

《实验六:数据库综合查询-答案》由会员上传分享,免费在线阅读,更多相关内容在教育资源-天天文库

1、实验六:数据库综合查询1.查询以‘DB_’开头,且倒数第个字符为‘s’的课程的详细情况;usestudentselect*fromcoursewherecnamelike'DB_%S__'2.查询名字中第个字为‘阳’的学生姓名和学号及选修的课程号、课程名;usestudentselectsname,student.sno,sc.cno,cnamefromcourse,student,scwheresnamelike'_阳%'andstudent.sno=sc.snoandcourse.cno=sc.cno3.列出选修了‘数学’或者‘大学英语’的学生学号、姓名、所在院系、选修课

2、程号及成绩;usestudentselectstudent.sno学号,sname姓名,sdept所在院系,sc.cno选修课程号,grade成绩fromcourse,student,scwhere(cname='数学'orcname='大学英语')andstudent.sno=sc.snoandcourse.cno=sc.cno4.查询缺少成绩的所有学生的详细情况;usestudentselectstudent.*fromstudent,scwheregradeisnullandstudent.sno=sc.sno注意:若成绩存在,则改为grade=数字1.查询与‘张力’(

3、假设姓名唯一)年龄不同的所有学生的信息usestudentselect*fromstudentwheresage!=(selectsagefromstudentwheresname='张力')2.查询所选课程的平均成绩大于张力的平均成绩的学生学号、姓名及平均成绩;usestudentselectx.sno学号,sname姓名,平均成绩=AVG(grade)fromstudentx,scygroupbysname,x.snohavingavg(grade)>(selectAVG(grade)fromsc,studentwheresname='张力'andsc.sno=stude

4、nt.sno)注意:没有成功1.按照“学号,姓名,所在院系,已修学分”的顺序列出学生学分的获得情况。其中已修学分为考试已经及格的课程学分之和;usestudentselectstudent.sno学号,sname姓名,sdept院系,已修学分=(SUM(casewhengrade>60thenccreditelse0end))fromstudent,sc,coursewherestudent.sno=sc.snoandsc.cno=course.cnogroupbystudent.sno,sname,sdept2.列出只选修一门课程的学生的学号、姓名、院系及成绩usestud

5、entselectsc.sno学号,sname姓名,sdept院系,grade成绩fromstudent,scwherestudent.sno=sc.snoandstudent.snoin(selectsc.snofromstudent,scwherestudent.sno=sc.snogroupbysc.snohavingcount(sc.cno)=1);3.查找选修了至少一门和张力选修课程一样的学生的学号、姓名及课程号;usestudentselectsc.sno学号,sname姓名,cno课程号fromstudent,scwherestudent.sno=sc.snoa

6、ndsc.cnoin(selectsc.cnofromstudent,scwherestudent.sno=sc.snoandstudent.sname='张力')andsname<>'张力'/*此句意思是不包括张力*/10.只选修“数据库”和“数据结构”两门课程的学生的基本信息;usestudentselectstudent.*fromstudent,sc,coursewherestudent.sno=sc.snoandsc.cno=course.cnoandsc.snoin(selectsc.snofromsc,coursewherecourse.cname='数据库'a

7、ndcourse.cname='数据结构、、'groupbysc.snohavingCOUNT(sc.cno)=2)11.至少选修“数据库”或“数据结构”课程的学生的基本信息selectstudent.*fromstudent,sc,coursewherestudent.sno=sc.snoandsc.cno=course.cnoandcname='数据结构'andstudent.snoin(selectstudent.snofromstudent,sc,coursewherestudent.sno=s

当前文档最多预览五页,下载文档查看全文

此文档下载收益归作者所有

当前文档最多预览五页,下载文档查看全文
温馨提示:
1. 部分包含数学公式或PPT动画的文件,查看预览时可能会显示错乱或异常,文件下载后无此问题,请放心下载。
2. 本文档由用户上传,版权归属用户,天天文库负责整理代发布。如果您对本文档版权有争议请及时联系客服。
3. 下载前请仔细阅读文档内容,确认文档内容符合您的需求后进行下载,若出现内容与标题不符可向本站投诉处理。
4. 下载文档时可能由于网络波动等原因无法下载或下载错误,付费完成后未能成功下载的用户请联系客服处理。