sql50例.docVIP

  • 10
  • 0
  • 约1.26万字
  • 约 19页
  • 2016-12-01 发布于河南
  • 举报
sql50例

sql50例 数据字典 Student(id,name,age,sex) 学生表 Course(id,name,tid) 课程表 SC(Sid,Cid,score) 成绩表 Teacher(id,name) 教师表 问题: 1、查询“001”课程比“002”课程成绩高的所有学生的学号; select a.id from (select id,score from SC where id=001) a,(select id,score from SC where id=002) b where a.scoreb.score and a.id=b.id; 2、查询平均成绩大于60分的同学的学号和平均成绩; select id,avg(score) from sc group by id having avg(score) 60; 3、查询所有同学的学号、姓名、选课数、总成绩; select Student.id,Student.Sname,count(SC.id),sum(score) from Student left Outer join SC on Student.id=SC.id group by Student.id,Sname 4、查询姓“李”的老师的个数; select count(distinct(

文档评论(0)

1亿VIP精品文档

相关文档