|
select /*+use_hash(a b) full(a) full(b) */
a.user_name,count(*) dup_num,
sum(least(a.stop_time,b.stop_time)-b.start_time) duptime_sum
from
adsl11_detail a,adsl11_detail b
where
a.user_name=b.user_name
and a.nas_ip=b.nas_ip
and a.nas_port=b.nas_port
and a.start_time<b.start_time and a.stop_time-1/288>b.start_time
and a.frame_ip!=b.frame_ip
group by
a.user_name
having
count(*)!=0;
这个sql改成这个好一点不?
[PHP]
select /*+use_hash(a b) full(a) full(b) */
a.user_name,count(*) dup_num,
sum(least(a.stop_time,b.stop_time)-b.start_time) duptime_sum
from
adsl11_detail a,adsl11_detail b
where
a.user_name=b.user_name
and a.nas_ip=b.nas_ip
and a.nas_port=b.nas_port
and a.start_time<b.start_time and a.stop_time>b.start_time+1/288
and a.frame_ip!=b.frame_ip
group by
a.user_name
having
count(*)>0;
/[/PHP]
看到各位大师的分析,学了不少 ! |
|