: 少“学号”字段select 学号 from stu where 学号 in(select top 3 学号 from  where 代号='001' order by 成绩 desc)

解决方案 »

  1.   

    將成績降序排,然後 select top 3 学号即可,樓主的三個表是不是少了字段?
      

  2.   

     少一个学号字段
    select 学号
    from 
    where 课程号=101 or 课程号=102
    group by 学号
    having count(学号)=2
      

  3.   

    少一个学号字段,  
    select 学号
    from 
    where 课程号=101 or 课程号=102
    group by 学号
    having count(学号)=2
      

  4.   

    少一个学号字段,  
    select 学号
    from 
    where 课程号=101 or 课程号=102
    group by 学号
    having count(学号)=2
    谢谢小鱼,我想知道用嵌套如何实现这个结果?
      

  5.   

    select 学号
    from  xs_kc
    where 课程号=101 
      and  学好 in(select 学号
                   from  xs_kc  
                  where  课程号=102)
      

  6.   

    select stu.姓名 from stu.suject,
    where stu.学号 = suject.学号 and suject.代号 = .代号
    and exists(select * from suject where 代号 = '101' or 代号 = '102' having count(*)>1)
    晕 这样写似乎很笨
      

  7.   

    改进一下:
    select 姓名 from stu where 学号 in
    (select 学号 from suject where 代号 = '101' or 代号 = '102' having count(*)>1)