读书人

oracle统计无记要时写默认值

发布时间: 2012-12-27 10:17:10 作者: rapoo

oracle统计无记录时,写默认值

?

select ?nvl(max(t1.packagesize),0) ?

from (

? ? ? ? select decode(count(t.per_bus_code),0,'1') per_bus_code,decode(count(t.buss_code),0,'1') buss_code,decode(count(t.per_code),0,'1') per_code?

? ? ? ? ? ?from t_tybook_back_pers_business t

? ? ? ? ? ?where t.per_code = 'TY-00000106'?

? ? ? ? ? ?and t.end_date > sysdate?

? ? ? ? ? ?and t.start_date<=sysdate ) t

left join t_tybook_before_business t1 on t.buss_code = t1.code?

group by t.per_code;

?

?

读书人网 >其他数据库

热点推荐