程序師世界是廣大編程愛好者互助、分享、學習的平台,程序師世界有你更精彩!
首頁
編程語言
C語言|JAVA編程
Python編程
網頁編程
ASP編程|PHP編程
JSP編程
數據庫知識
MYSQL數據庫|SqlServer數據庫
Oracle數據庫|DB2數據庫
 程式師世界 >> 數據庫知識 >> Oracle數據庫 >> Oracle數據庫基礎 >> 多庫SQL union 查詢代碼

多庫SQL union 查詢代碼

編輯:Oracle數據庫基礎
 

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

 
  1. 上一頁:
  2. 下一頁:
Copyright © 程式師世界 All Rights Reserved