--Student(S#,Sname,Sage,Ssex) 学生表 
--Course(C#,Cname,T#) 课程表 
--SC(S#,C#,score) 成绩表 
--Teacher(T#,Tname) 教师表 --1、查询“001”课程比“002”课程成绩高的所有学生的学号;这样写行嘛?select a.s# as 学号 from student as a 
where score1(select score from sc as c where c#='001')
>score2(select score from sc as c where c#='002') 
and a.s#=c.s#

不行的话,请你写出你能想到的一种或几种

解决方案 »

  1.   

    select a.* from student a
    inner join sc b
    on b.s#=a.s#
    inner join sc c
    on c.s#=a.s#
    where b.c#='001' and c.c#='002' and b.score>c.score基本上就这样了。不换思路换语法随便套都能套出很多种 ,没有意义比如select a.* from student a,sc b,sc c
    where .....或是select a.* from student a
    where (select score from sc where s#=a.s# and c#='001')
    >
    (select score from sc where s#=a.s# and c#='002')
    ...
      

  2.   

    --SC(S#,C#,score) 成绩表 
    --Teacher(T#,Tname) 教师表 --1、查询“001”课程比“002”课程成绩高的所有学生的学号;select * from (select * from SC where c#='001') a ,(select * from SC where c#='001') b
     where a.s#=b.s#
     
      

  3.   


    select * from (select * from SC where c#='001') a ,(select * from SC where c#='002') b
     where a.s#=b.s#
      

  4.   


    后面要加个a.score>b.score吧
      

  5.   

    select sno
    from sc_table
    where cno='1' and  scgrade>
    (
    select scgrade
    from sc_table
    where sno='2' and cno='1'
    )
    group by sno