是where语句限制掉了.如果想实现你所要的结果得写得复杂些

解决方案 »

  1.   

    如果去掉group by,还能查询么?
      

  2.   

    你写成nvl(count(*),0)不就行了
      

  3.   

    Oracle:
    select a.f1, nvl(ct,0)
    from 

      select f1,count(*) ct from table1 where f2=xxx
    ) a,
    (
      select distinct f1 from table1
    ) b
    where a.f1(+)=b.f1;
    如果有另外的表存储所有的f1,可用它代替子查询b
      

  4.   

    to MountLion:
    直接用nvl就可以了,为什么要那么复杂?
    It's my sql:
    select f1,nvl(count(*),0)
    from table1
    where f2 = xxx
    group by f1