select count(*) as f,
s.deal_unit_id,
s.bill_type,
s.deal_staff_id ,
(SELECT UNIT_NAME FROM T_UNIT WHERE UNIT_ID=s.deal_unit_id AND ROWNUM<2) UNIT_NAME ,
(select count(*)
from (select serv_info_id,deal_unit_id,timeout_flag3,deal_staff_id,bill_type
from t_serv_info union select serv_info_id,deal_unit_id,timeout_flag3,deal_staff_id,bill_type from t_serv_info_his)
where deal_unit_id = s.deal_unit_id
and deal_staff_id = s.deal_staff_id
and bill_type = s.bill_type) TOTAL2
from (select serv_info_id,deal_unit_id,timeout_flag3,deal_staff_id,bill_type from t_serv_info union select serv_info_id,deal_unit_id,timeout_flag3,deal_staff_id,bill_type from t_serv_info_his) s
where s.timeout_flag3 = 'T'
group by s.deal_unit_id ,
s.deal_staff_id,
s.bill_type
select count(*) TOTAL1,
s.deal_unit_id,
s.bill_type,
s.deal_staff_id ,
(SELECT UNIT_NAME FROM T_UNIT WHERE UNIT_ID=s.deal_unit_id AND ROWNUM<2) UNIT_NAME ,
substr((count(*)/(select count(*)
from (select *
from t_serv_info union select * from t_serv_info_his)
where deal_unit_id = s.deal_unit_id
and deal_staff_id = s.deal_staff_id
and bill_type = s.bill_type)
),1,5)*100 TOTAL2
from (select * from t_serv_info union select * from t_serv_info_his) s
where s.timeout_flag3 = 'T'
group by s.deal_unit_id ,
s.deal_staff_id,
s.bill_type
10秒 83秒 18秒 12秒