union 横向组合

浪尽此生 提交于 2020-04-01 05:36:03

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')
)

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!