1,请写出表A中有 表B中没有的数据   (A B表中字段为ID)2,表C 字段分别为 id sex class  
a)请查出至少有10位男生的班级
b)请查出至少有10位男生并且至少有5为女生的班级谢谢 !

解决方案 »

  1.   

    select * from A where id not in (select id from B)
    select class from c where sex='男' group by class having count(id)>=0
    select class from c group by having count(case when sex='男' then 1 else 0 end)>10
    and count(case when sex='女' then 1 else 0 end)>5
      

  2.   

    select * from A where id not in (select id from B)
    select class from c where sex='男' group by class having count(id)>=10
    select class from c group by class having count(case when sex='男' then 1 else 0 end)>=10
    and count(case when sex='女' then 1 else 0 end)>=5
      

  3.   

    请问  case when sex='男' then 1 else 0 end   放在count 是什么意思 不太理解  谢谢
      

  4.   

    如果是男就给1 如果是女就0你把count 改成sum 吧