begin
    select ...;
    exception when no_data_found then
      ...;
end;

解决方案 »

  1.   

    select greatest(sum(qty),nvl(qty,0)) from table1 where name='lile' group by name
      

  2.   

    select decode(sum(qty),0,0,sum(qty)) from ecm_cid_type;
      

  3.   

    sorry,to_be is: 
    select sum(nvl(qty,0)) from table1 where name='lile' group by name;
      

  4.   

    select decode(sum(qty),0,0,sum(qty)) from table1 where name='lile' group by name
      

  5.   

    不行呀?BlueskyWide(谈趣者),拜托各位大哥了?
      

  6.   

    select nvl(a,0) from 
    (select sum(qty) a from table1 where name='lile' group by name)
      

  7.   

    给位大哥都不行呀,都返回 %notfound,没有纪录返回 
    我要的是至少返回一条纪录,我想可能是实现不了的,因为table没有lile这条纪录,nvl只能
    处理null 值,不能处理没有纪录,郁闷
      

  8.   

    再试:
    select sum(nvl(qty,0)) from table1 where name like 'lile' group by name;
      

  9.   

    select decode(sum(qty),null,0,sum(qty)) from table1 where name='lile' group by name
      

  10.   

    的确是这样的,应该先:
    update table1 set name='0' where name is null;
    commit;
    再:select sum(nvl(qty,0)) from table1 where name='lile' group by name;
      

  11.   

    你这个没有必要要分组吧
    不分组的话,这个可以
    select decode(sum(qty),null,0,sum(qty)) from table1 where name='lile' ;
      

  12.   

    select NVL(sum(NVL(qty,0),0) from table1 where name='lile'
    不需要后面的GROUP BY 即可