数据库24个查询代码.docxVIP

  1. 1、本文档共3页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
  5. 5、该文档为VIP文档,如果想要下载,成为VIP会员后,下载免费。
  6. 6、成为VIP后,下载本文档将扣除1次下载权益。下载后,不支持退款、换文档。如有疑问请联系我们
  7. 7、成为VIP后,您将拥有八大权益,权益包括:VIP文档下载权益、阅读免打扰、文档格式转换、高级专利检索、专属身份标志、高级客服、多端互通、版权登记。
  8. 8、VIP文档为合作方或网友上传,每下载1次, 网站将根据用户上传文档的质量评分、类型等,对文档贡献者给予高额补贴、流量扶持。如果你也想贡献VIP文档。上传文档
查看更多
数据库24个查询代码 数据库24个查询代码 --1. 查询学生的基本信息; select * from student go --2. 查询“CS ”系学生的基本信息; select * from student where sdept=cs go --3. 查询“CS ”系学生年龄不在19到21之间的学生的学号、姓名; select sno,sname from student where sdept=cs and sage not between 19 and 21 go --4. 找出最大年龄; select max(sage) from student go --5. 找出“CS ”系年龄最大的学生,显示其学号、姓名; select sno,sname from student where sdept=cs and sage=(select max(sage) from student where sdept=cs ) go --6. 找出各系年龄最大的学生,显示其学号、姓名; select sno,sname,sdept from student s1 where sage=(select max(sage) from student where sdept=s1.sdept ) go --7. 统计“CS ”系学生的人数; select count(*) from student where sdept=cs go --8. 统计各系学生的人数,结果按升序排列; select sdept,count(sno) from student group by sdept order by count(sno) go --9. 按系统计各系学生的平均年龄,结果按降序排列; select sdept,avg(sage) as sm from student group by sdept order by sm desc go --10. 查询每门课程的课程名; select cno,cname from course go --11. 查询无先修课的课程的课程名和学分; select cname,ccredit from course where cpno is null go --12. 统计无先修课的课程的学分总数;select * from course select sum(ccredit) from course where cpno is null go --13. 统计每位学生选修课程的门数、学分及其平均成绩; select sno,count(sc.cno),sum(ccredit),avg(grade) from sc,course where sc.cno=course.cno group by sno go --14. 统计选修每门课程的学生人数及各门课程的平均成绩; select cno,count(sno),avg(grade) from sc from sc select distinct sno group by cno from sc go --15. 找出平均成绩在85分以上的学生,结果 按系分组,并按平均成绩的升序排列; select sdept,sc.sno,avg(scores) from sc,student where sc.sno=s.sno group by sc.sno,sdept having avg(scores)85 go --16. 查询选修了“1”或“2”号课程的学生学号和姓名; select sc.sno,sname from sc,student where sc.sno=student.sno and (sc.cno=1 or sc.cno=2) go --17. 查询选修了“1”和“2”号课程的学生 select sc.sno,sname from sc,student where sc.sno=student.sno and sc.cno=1 and sc.sno in(select sno where cno=2) go --18. 查询选修了课程名为“数据库系统”且成绩在60分以下的学生的学号、姓名和成绩; select sc.sno,sname,grade from sc,student,course where sc.sno=student.sno and sc.cno=course.cno and course.cna

文档评论(0)

180****8756 + 关注
官方认证
文档贡献者

该用户很懒,什么也没介绍

认证主体盛世风云(深圳)网络科技有限公司
IP属地湖南
统一社会信用代码/组织机构代码
91440300069269024M

1亿VIP精品文档

相关文档