怎么下这样的sql,select sum(qty) from table1 where name='lile' group by name 当没有lile这条纪录时自动返回 sum(qty) =0 ,
begin
select ...;
exception when no_data_found then
...;
end;
select ...;
exception when no_data_found then
...;
end;
解决方案 »
- 求助:oracle新手,请问这个包的注释该怎么写???谢谢了
- 关于用户对表的操作权限的问题
- ORA-04021: 等待锁定对象 ULTRANMS.AGGRE_PROVINCE_CONDIRECTION 时发生超时
- Oracle 创建对象类型失败
- 一个获取oracle日期的问题啊 急啊 高手们请进 在线等待!!!
- SQL问题
- windows XP安装 oracle 10g client 问题
- SQL语句的写法
- 求助!关于/*+ALL_ROWS*/
- Oracle 不能自動啟動數據庫(win2000+oracle8.1.7)
- (求助)组合查询问题,在线等待,100分
- 在存储过程中临时表怎样创建 ?怎么把临时表的结果集传出?
select sum(nvl(qty,0)) from table1 where name='lile' group by name;
(select sum(qty) a from table1 where name='lile' group by name)
我要的是至少返回一条纪录,我想可能是实现不了的,因为table没有lile这条纪录,nvl只能
处理null 值,不能处理没有纪录,郁闷
select sum(nvl(qty,0)) from table1 where name like 'lile' group by name;
update table1 set name='0' where name is null;
commit;
再:select sum(nvl(qty,0)) from table1 where name='lile' group by name;
不分组的话,这个可以
select decode(sum(qty),null,0,sum(qty)) from table1 where name='lile' ;
不需要后面的GROUP BY 即可