oracle 一句sql 执行速度特别慢,请指导如何改写,谢谢
selectf.channel_name,c.name,c.rule_detail,count(*)monthly,rank()over(orderbycount(*)d...
select f.channel_name,c.name, c.rule_detail,count(*) monthly, rank() over(order by count(*) desc) rank from cljy.sys_cljy c,channel_paylog_day f where SUBSTR(f.recv_time,1,6)=
to_char(sysdate,'yyyymm') and c.name like'%经典%' and exists(select * from cljy.sys_pay_prize_target j,nt_staff_channel g where f.serial_number=j.device_number and f.recv_depart_id=g.depart_id) group by f.channel_name,c.name,c.rule_detail 展开
to_char(sysdate,'yyyymm') and c.name like'%经典%' and exists(select * from cljy.sys_pay_prize_target j,nt_staff_channel g where f.serial_number=j.device_number and f.recv_depart_id=g.depart_id) group by f.channel_name,c.name,c.rule_detail 展开
1个回答
展开全部
select f.channel_name,c.name, c.rule_detail,count(1) monthly, rank() over(order by count(1) desc) rank
from cljy.sys_cljy c,channel_paylog_day f where SUBSTR(f.recv_time,1,6)=
to_char(sysdate,'yyyymm') and c.name like'%经典%' and
exists(select count(1) from cljy.sys_pay_prize_target j,nt_staff_channel g where j.device_number=f.serial_number and g.depart_id=f.recv_depart_id) --and rownum <2
group by f.channel_name,c.name,c.rule_detail
先把and rownum <2 注释去掉 能执行成功的话 就没错,老感觉这个语句死循环了。。。测完再回复我,给你看
追问
谢谢,可以执行,能取到数,执行速度慢原因在...exists(select * from...,把*改成你的count(1)就能很快执行了
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询