风
风信紫
Unregistered / Unconfirmed
GUEST, unregistred user!
sql语句为:
select ada.txgz,adb.gyjf,(ada.txgz+adb.gyjf+adc.dqt) as ydcount,
(ae.qtgz+aea.zggz+aeb.lsggz) as jtcount,adc.dqt,ae.qtgz,aea.zggz,aeb.lsggz,cod.tet from
((((((select dwmc as tet,dwdm from dwdm) cod LEFT JOIN
(select sum(fendbal) as txgz,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where kmmc='手机费')) AND (FCYID='RMB' )AND (FPERIOD=1) group by fdwdm ) ada ON COD.DWDM=ADA.FDWDM) LEFT JOIN
(select sum(fendbal) as gyjf,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where kmmc='办公电话费')) AND (FCYID='RMB') AND (FPERIOD=1) group by fdwdm ) adb ON COD.DWDM=ADB.FDWDM) LEFT JOIN
(select sum(fendbal) as dqt,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where kmmc='住宅电话费') and (dwdm=0))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=1))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=2))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=3))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=4))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=5))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=6))) AND (FCYID='RMB') AND (FPERIOD=1) group by fdwdm ) adc ON COD.DWDM=ADC.FDWDM) LEFT JOIN
(select sum(fendbal) as qtgz,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=0))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=1))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=2))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=3))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=4))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=5))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=6))) AND (FCYID='RMB') AND (FPERIOD=1) group by fdwdm ) ae ON COD.DWDM=AE.FDWDM) LEFT JOIN
(select sum(fendbal) as zggz,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=0))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=1))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=2))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=3))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=4))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=5))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=6))) AND (FCYID='RMB') AND (FPERIOD=1 ) group by fdwdm ) aea ON COD.DWDM=AEA.FDWDM) LEFT JOIN
(select sum(fendbal) as lsggz,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=0))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=1))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=2))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=3))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=4))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=5))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=6))) AND (FCYID='RMB') AND (FPERIOD=1) group by fdwdm ) aeb ON COD.DWDM=AEB.FDWDM
ada.txgz,adb.gyjf,adc.dqt可能为空,怎样使ydcount不为空?
select ada.txgz,adb.gyjf,(ada.txgz+adb.gyjf+adc.dqt) as ydcount,
(ae.qtgz+aea.zggz+aeb.lsggz) as jtcount,adc.dqt,ae.qtgz,aea.zggz,aeb.lsggz,cod.tet from
((((((select dwmc as tet,dwdm from dwdm) cod LEFT JOIN
(select sum(fendbal) as txgz,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where kmmc='手机费')) AND (FCYID='RMB' )AND (FPERIOD=1) group by fdwdm ) ada ON COD.DWDM=ADA.FDWDM) LEFT JOIN
(select sum(fendbal) as gyjf,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where kmmc='办公电话费')) AND (FCYID='RMB') AND (FPERIOD=1) group by fdwdm ) adb ON COD.DWDM=ADB.FDWDM) LEFT JOIN
(select sum(fendbal) as dqt,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where kmmc='住宅电话费') and (dwdm=0))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=1))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=2))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=3))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=4))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=5))) or (FAcctID=(select kmdm from kmdm where (kmmc='住宅电话费') and (dwdm=6))) AND (FCYID='RMB') AND (FPERIOD=1) group by fdwdm ) adc ON COD.DWDM=ADC.FDWDM) LEFT JOIN
(select sum(fendbal) as qtgz,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=0))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=1))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=2))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=3))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=4))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=5))) or (FAcctID=(select kmdm from kmdm where (kmmc='车修费') and (dwdm=6))) AND (FCYID='RMB') AND (FPERIOD=1) group by fdwdm ) ae ON COD.DWDM=AE.FDWDM) LEFT JOIN
(select sum(fendbal) as zggz,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=0))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=1))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=2))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=3))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=4))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=5))) or (FAcctID=(select kmdm from kmdm where (kmmc='车燃费') and (dwdm=6))) AND (FCYID='RMB') AND (FPERIOD=1 ) group by fdwdm ) aea ON COD.DWDM=AEA.FDWDM) LEFT JOIN
(select sum(fendbal) as lsggz,fdwdm from glbal where (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=0))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=1))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=2))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=3))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=4))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=5))) or (FAcctID=(select kmdm from kmdm where (kmmc='交通其他') and (dwdm=6))) AND (FCYID='RMB') AND (FPERIOD=1) group by fdwdm ) aeb ON COD.DWDM=AEB.FDWDM
ada.txgz,adb.gyjf,adc.dqt可能为空,怎样使ydcount不为空?