假如有三张表:
学生表s(学号,姓名,性别)
课程表c(课程号,课程名)
成绩表sc(学号,课程号,成绩)
求:成绩>60的学生的姓名,性别
求:课程名为'数学',成绩>70的学生的姓名,按学生的成绩降序排。

解决方案 »

  1.   

    第一题:select 姓名,性别 from s,c,sc where a.学号=sc.学号 and sc.课程号=c.课程号 and 成绩>60;
    第二题:select 姓名 from s,c,sc where a.学号=sc.学号 and sc.课程号=c.课程号 and 成绩>70
    and 课程名='数学' order by 成绩 desc;
      

  2.   

    1.select 姓名,性别 from s where exists (select 1 from sc where sc.学号=s.学好 and sc.成绩>10)
    2.select 姓名 from s,sc where sc.学号=s.学号 and exists (select 1 from c where c.课程号=sc.课程号 and c.课程名='数学')
      

  3.   

    1.select 姓名,性别 from s where exists (select 1 from sc where sc.学号=s.学好 and sc.成绩>10)
    2.select 姓名 from s,sc where sc.学号=s.学号 and exists (select 1 from c where c.课程号=sc.课程号 and c.课程名='数学')  and sc.成绩>70 order by sc.成绩 desc
      

  4.   

    select sex,grade from s
    join s on sc where sc.grade >60 and sc.number= s.number你看看对不对,我也没试过