select gg.h
from B gg , A mm
where gg.h=1 and
      gg.f=mm.f and
      mm.d>0
group by gg.h
having 2 * (select count(1) from mm where e between ('2005-01-01','2005-11-01')) > 
       (select count(1) from mm where e between ('2004-01-01','2004-11-01' ))

解决方案 »

  1.   

    --不好意思,上面Group By和Select出来的是 f
    select gg.f
    from B gg , A mm
    where gg.h=1 and
          gg.f=mm.f and
          mm.d>0
    group by gg.f
    having 2 * (select count(1) from mm where e between ('2005-01-01','2005-11-01')) > 
           (select count(1) from mm where e between ('2004-01-01','2004-11-01' ))