select sum(zs) zs,sum(zl) zl,sum(ts) ts,sum(lxcbw) lxcbw,sum(bz) bz,sum(sfzqt) sfzqt
from (
select count(distinct sqh) zs,0 zl,0 ts,0 lxcbw,0 bz,0 sfzqt from **** where pici = '673' and chuandate = '20190701'
union all
select 0 zs,count( sqh) zl,0 ts,0 lxcbw,0 bz,0 sfzqt from ***** where sqh in(
select sqh from ywbl_scyyw_chuan where pici = '673' and chuandate = '20190701')
union all
select 0 zs,0 zl,count( sqh) ts,0 lxcbw,0 bz,0 sfzqt from **** where sqh in(
select sqh from ywbl_scyyw_chuan where pici = '673' and chuandate = '20190701')
union all
select 0 zs,0 zl,0 ts,count( sqh) lxcbw,0 bz,0 sfzqt from ***** where sqh in(
select sqh from ywbl_scyyw_chuan where pici = '673' and chuandate = '20190701')
union all
select 0 zs,0 zl,0 ts,0 lxcbw ,count( sqh) bz,0 sfzqt from ***** where sqh in(
select sqh from ywbl_scyyw_chuan where pici = '673' and chuandate = '20190701')
union all
select 0 zs,0 zl,0 ts,0 lxcbw,0 bz,count( sqh) sfzqt from **** where sqh in(
select sqh from ywbl_scyyw_chuan where pici = '673' and chuandate = '20190701')
)
来源:https://www.cnblogs.com/lxl-six/p/11115407.html