`
king123654789
  • 浏览: 286768 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

多库SQL union 查询

 
阅读更多

select protype 类型,sum(procount) 数量 from
(
select trim('未解决数量') protype,count(distinct t1.c1) procount from {4} t1
where t1.c809000021<>'已关闭'
and t1.c700000006>{1}
and t1.c700000006<{2}
and t1.c809000012='{3}'
and t1.c809000021='已关闭'
and t1.c809000001 is not null--类别
union
select trim('未解决数量') protype,count(distinct t2.c1) procount from {5} t2
where t2.c700000010<>'已关闭'
and t2.c700000006>{1}
and t2.c700000006<{2}
and t2.c811020016='{3}'
and t2.c700000010='已关闭'
and t2.c811020001 is not null--类别
)
group by protype
union all
select protype 类型,sum(procount) 数量 from
(
select trim('已解决数量') protype,count(distinct t3.c1) procount from {4} t3
where t3.c809000021='已关闭'
and t3.c700000006>{1}
and t3.c700000006<{2}
and t3.c809000012='{3}'
and t3.c809000021='已关闭'
and t3.c809000001 is not null--类别
union
select trim('已解决数量') protype,count(distinct t4.c1) procount from {5} t4
where t4.c700000010='已关闭'
and t4.c700000006>{1}
and t4.c700000006<{2}
and t4.c811020016='{3}'
and t4.c700000010='已关闭'
and t4.c811020001 is not null--类别
)
group by protype

分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics