第三章关系数据库语言1.ppt

  1. 1、本文档共42页,可阅读全部内容。
  2. 2、原创力文档(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
第三章关系数据库语言1.ppt

* * 1、Select sex,avg(grade) as avg_g from Student group by sex 2、select sno,name from student where grade60 and sex=‘男’ order by grade desc (或 order by -grade) 3、select b.sno,b.name from student a,student b where b.grade=60 and b.gradea.grade and a.sno=‘005’ 或 select * from eg1_student where grade=60 and grade(select grade from eg1_student where sno=005) * Student/Course/Grade * 1、select b.cname,max(a.grade) max_grade from eg2_grade a,eg2_course b where a.cno=b.cno group by b.cname 2、select b.cname,b.dept,count(a.sno) cnt from eg2_grade a,eg2_course b where a.cno=b.cno group by b.cname,b.dept having count(a.sno)=2 order by cnt 3、select sno,sname,year(getdate())-year(sbirth) age from eg2_student where datediff(year,sbirth,getdate())24 * 1、select ename,pay+allowance+prize-deduction salary from eg3_employee a,eg3_wage b where a.eno=b.eno 2、select dname,min(ebirth) birth from eg3_department a,eg3_employee b where a.dno=b.dno group by dname 3、select dname,count(eno) cnt from eg3_department a,eg3_employee b where a.dno=b.dno group by dname having count(eno)=2 order by cnt desc D A(可作图分析) CHECK C 例子: create table tt ( f1 int check(f12) ) B SET AGE=AGE+1 用两个成绩表分别与学生信息表合并,作为中间表,然后再把中间表合并得到最终结果 Create view t1 as SELECT a.stu_id,name,score as mathscore FROM eg4_student a left JOIN eg4_math b ON a.stu_id=b.stu_id Create view t2 as SELECT a.stu_id,name,score as englishscore FROM eg4_student a left JOIN eg4_english b ON a.stu_id=b.stu_id select t1.*,t2.englishscore from t1 join t2 on t1.stu_id=t2.stu_id (思路同“中间表”法) select t1.*,t2.englishscore from (SELECT a.stu_id,name,score as mathscore FROM eg4_student a left JOIN eg4_math b ON a.stu_id=b.stu_id ) t1 join (SELECT a.stu_id,name,score as englishscore FROM eg4_student a left JOIN eg4_english b ON a.stu_id=b.stu_id ) t2 on t1.stu_id=t2.stu_id (以最完整的表为基准,进行两次左连接。) select a.stu_id,name,b.score englishscore,c.score mathscore from eg4_student a left join eg4_math b on a.stu_id=b.stu_id left join eg4_english c on

文档评论(0)

资料 + 关注
实名认证
内容提供者

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

1亿VIP精品文档

相关文档