9-SQL50例.pdfVIP

  • 11
  • 0
  • 约1.29万字
  • 约 9页
  • 2017-08-23 发布于河南
  • 举报
9-SQL50例

Student(Sid,Sname,Sage,Ssex) 学生表 Course(Cid,Cname,Tid) 课程表 SC(Sid,Cid,score) 成绩表 Teacher(Tid,Tname) 教师表 问题: 1、查询“001 ”课程比“002 ”课程成绩高的所有学生的学号; select a.SID from (select Sid,score from SC where CID=001) a,(select Sid,score from SC where CID=002) b where a.scoreb.score and a.Sid=b.Sid; 2 、查询平均成绩大于60 分的同学的学号和平均成绩; select SID,avg(score) from sc group by SID having avg(score) 60; 3、查询所有同学的学号、姓名、选课数、总成绩; select Student.SID,Student.Sname,count(SC.CID),sum(score) from Student left Outer join SC on Student.SID=SC.SID group by Student.SID,Sname 4 、查询姓“李”

文档评论(0)

1亿VIP精品文档

相关文档