学生表 studen(s_id,s_name) 课程表 class(c_id,c_name)选课表 study(id,s_id,c_id) 查询出选了2门课以上的学生信息,

解决方案 »

  1.   

    select s_id,s_name
    from students a
    join 
    (
    select s_id,count(c_id)
    from study
    group by sid
    having count(c_id)>2)  b
    on(a.s_id=b.s_id)
      

  2.   

    having count(c_id)>2是什么意思啊,
      

  3.   


    就是2门课以上的学生,如果你所谓的2门课以上包含2,那么就是having count(c_id)>=2就可以了
      

  4.   

    如楼上所说,lz最好再看看sql相关的资料
      

  5.   

    谢谢,我今天就是没写出来having.....都不知道还可以这么写
      

  6.   

    建议楼主看这本书: SQL Reference, download-west.Oracle.com上有下载
      

  7.   

    select * from (select * from study where count(s_id)>'2') ta,student tb where ta.s_id=tb.s_id;
      

  8.   

    select * from (select * from study where count(s_id)>'2') ta,student tb where ta.s_id=tb.s_id;
      

  9.   


    这个对吗,select * from study where count(s_id)>'2'是什么意思啊,