select dic.name, NVL(zc.zc_djzs,0),NVL(zc.zc_shzs,0),NVL(zc.zc_bzzs,0),
NVL(zt.zt_djzs,0),NVL(zt.zt_shzs,0),NVL(zt.zt_bzzs,0),
NVL(dc.dc_djzs,0),NVL(dc.dc_shzs,0),NVL(dc.dc_bzzs,0),
NVL(qk.qk_djzs,0),NVL(qk.qk_shzs,0),NVL(qk.qk_bzzs,0),
NVL(bk.bk_djzs,0),NVL(bk.bk_shzs,0),NVL(bk.bk_bzzs,0)
from
(select zc.LRDWDM,
sum( case when zc.spzt='01' then 1 when zc.spzt='02' then 1 when zc.spzt='03' then 1 ELSE 0 END ) as zc_djzs,
sum( case when zc.spzt='03' then 1 ELSE 0 END ) as zc_shzs,
sum( case when zc.spzt='03' and zc.ZWBZZTDM='04' then 1 ELSE 0 END ) as zc_bzzs
from YW_ZWXC_ZCRWQQ zc group by zc.LRDWDM) zc,
(select zt.lrdwdm,
sum( case when zt.spzt='01' then 1 when zt.spzt='02' then 1 when zt.spzt='03' then 1 ELSE 0 END ) as zt_djzs,
sum( case when zt.spzt='03' then 1 ELSE 0 END ) as zt_shzs,
sum( case when zt.spzt='03' and zt.ZWBZZTDM='04' then 1 ELSE 0 END ) as zt_bzzs
from YW_ZWXC_SZZWZTRWQQ zt group by zt.lrdwdm) zt,
(select dc.LRDWDM,
sum( case when dc.spzt='01' then 1 when dc.spzt='02' then 1 when dc.spzt='03' then 1 ELSE 0 END ) as dc_djzs,
sum( case when dc.spzt='03' then 1 ELSE 0 END ) as dc_shzs,
sum( case when dc.spzt='03' and dc.ZWBZZTDM='04' then 1 ELSE 0 END ) as dc_bzzs
from YW_ZWXC_DCRWQQ dc group by dc.LRDWDM) dc,
(select qk.LRDWDM,
sum( case when qk.spzt='01' then 1 when qk.spzt='02' then 1 when qk.spzt='03' then 1 ELSE 0 END ) as qk_djzs,
sum( case when qk.spzt='03' then 1 ELSE 0 END ) as qk_shzs,
sum( case when qk.spzt='03' and qk.ZWBZZTDM='04' then 1 ELSE 0 END ) as qk_bzzs
from YW_ZWXC_QKJLXCRWQQ qk group by qk.LRDWDM) qk,
(select bk.LRDWDM,
sum( case when bk.spzt='01' then 1 when bk.spzt='02' then 1 when bk.spzt='03' then 1 ELSE 0 END ) as bk_djzs,
sum( case when bk.spzt='03' then 1 ELSE 0 END ) as bk_shzs,
sum( case when bk.spzt='03' and bk.ZWBZZTDM='04' then 1 ELSE 0 END ) as bk_bzzs
from YW_ZWXC_SZZWBKRWQQ bk group by bk.LRDWDM) bk,
sys_dictitem dic
where
zc.LRDWDM(+) = dic.code and zt.lrdwdm(+) = dic.code and dc.lrdwdm(+) = dic.code and qk.lrdwdm(+) = dic.code and bk.lrdwdm(+) = dic.code
and dic.groupid ='CODE_UNIT' ORDER BY ZC.zc_djzs ASC
NVL(zt.zt_djzs,0),NVL(zt.zt_shzs,0),NVL(zt.zt_bzzs,0),
NVL(dc.dc_djzs,0),NVL(dc.dc_shzs,0),NVL(dc.dc_bzzs,0),
NVL(qk.qk_djzs,0),NVL(qk.qk_shzs,0),NVL(qk.qk_bzzs,0),
NVL(bk.bk_djzs,0),NVL(bk.bk_shzs,0),NVL(bk.bk_bzzs,0)
from
(select zc.LRDWDM,
sum( case when zc.spzt='01' then 1 when zc.spzt='02' then 1 when zc.spzt='03' then 1 ELSE 0 END ) as zc_djzs,
sum( case when zc.spzt='03' then 1 ELSE 0 END ) as zc_shzs,
sum( case when zc.spzt='03' and zc.ZWBZZTDM='04' then 1 ELSE 0 END ) as zc_bzzs
from YW_ZWXC_ZCRWQQ zc group by zc.LRDWDM) zc,
(select zt.lrdwdm,
sum( case when zt.spzt='01' then 1 when zt.spzt='02' then 1 when zt.spzt='03' then 1 ELSE 0 END ) as zt_djzs,
sum( case when zt.spzt='03' then 1 ELSE 0 END ) as zt_shzs,
sum( case when zt.spzt='03' and zt.ZWBZZTDM='04' then 1 ELSE 0 END ) as zt_bzzs
from YW_ZWXC_SZZWZTRWQQ zt group by zt.lrdwdm) zt,
(select dc.LRDWDM,
sum( case when dc.spzt='01' then 1 when dc.spzt='02' then 1 when dc.spzt='03' then 1 ELSE 0 END ) as dc_djzs,
sum( case when dc.spzt='03' then 1 ELSE 0 END ) as dc_shzs,
sum( case when dc.spzt='03' and dc.ZWBZZTDM='04' then 1 ELSE 0 END ) as dc_bzzs
from YW_ZWXC_DCRWQQ dc group by dc.LRDWDM) dc,
(select qk.LRDWDM,
sum( case when qk.spzt='01' then 1 when qk.spzt='02' then 1 when qk.spzt='03' then 1 ELSE 0 END ) as qk_djzs,
sum( case when qk.spzt='03' then 1 ELSE 0 END ) as qk_shzs,
sum( case when qk.spzt='03' and qk.ZWBZZTDM='04' then 1 ELSE 0 END ) as qk_bzzs
from YW_ZWXC_QKJLXCRWQQ qk group by qk.LRDWDM) qk,
(select bk.LRDWDM,
sum( case when bk.spzt='01' then 1 when bk.spzt='02' then 1 when bk.spzt='03' then 1 ELSE 0 END ) as bk_djzs,
sum( case when bk.spzt='03' then 1 ELSE 0 END ) as bk_shzs,
sum( case when bk.spzt='03' and bk.ZWBZZTDM='04' then 1 ELSE 0 END ) as bk_bzzs
from YW_ZWXC_SZZWBKRWQQ bk group by bk.LRDWDM) bk,
sys_dictitem dic
where
zc.LRDWDM(+) = dic.code and zt.lrdwdm(+) = dic.code and dc.lrdwdm(+) = dic.code and qk.lrdwdm(+) = dic.code and bk.lrdwdm(+) = dic.code
and dic.groupid ='CODE_UNIT' ORDER BY ZC.zc_djzs ASC