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