查询速度优化

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秒

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值