select a.xsbh from a,b
where a.xsbh = b.xsbh 
group by a.xsbh 
having count(b.好事) >= 3;

解决方案 »

  1.   

    select xsbh
    from b
    group by xsbh
    having count(*) > 3
      

  2.   

    select xsbh from b
    group by xsbh
    having count(xsbh)>3
      

  3.   

    或者这样,效率会好点.少用having:
    select xsbh
    from b,(SELECT xsbh COUNT(1) cc FROM b GROUP BY xsbh) a
    WHERE a.xsbh=b.xsbh
      AND cc>3
      

  4.   

    select a.* 
    from a,(select xsbh,count(*) as n from b group by xsbh) c 
    where a.xsbh=c.xsbh and n>3
      

  5.   

    select a.*
    from a
    where exists (select b.xsbh from b where a.xsbh = b.xsbh 
    group by b.xsbh 
    having count(b.xsbh)>3)
      

  6.   

    sos_help(浊世清风) 的写法可以实现,不过效率不高,如果按我这样写的话,执行效率会高一些的