select nvl(sum(decode(status.CIP_STATUS,5,1,0)),0) as finishNum
,nvl(sum(case when globle.CIP_rapidType=2 and status.CIP_STATUS=0 then 1 else 0 end),0) as noApllyVeryRapid
,nvl(sum(case when globle.CIP_rapidType=1 and status.CIP_STATUS=0 then 1 else 0 end),0) as noApllyRapid
,nvl(sum(case when (globle.CIP_rapidType=0 or globle.CIP_rapidType is null) and status.CIP_STATUS=0 then 1 else 0 end),0) as noApllyNoRapid
,nvl(sum(decode(status.CIP_STATUS,0,1,0)),0) as noApplyNum
,nvl(sum(decode(status.CIP_STATUS,0,0,5,0,1)) ,0)as applyNoFinishNum
, count(status.CIPID) as totalNum
from CIP_rptCheckSTATUS status
,Cip_globleInfo globle
where status.cipid=globle.cipid(+)
and status.cipid not in(
select cipid
from Cip_EditInfo
where CIP_editType=2
and CIP_isDeal=1 )
为保万无一失,sum前加NVL即可,oracle下用NVL,SQL server 下用isnull