求助数据查询及导出问题
这个语句执行了好多个小时都无法执行出数据,有大佬知道怎么优化一下吗???要疯了
select count( *) from (
select cons_no,
(select prop_list_name from epm_ln.sa_prop_list where prop_type_id='plan_status' and prop_list_id=y.plan_status) 当前计划状态,
(select prop_list_name from epm_ln.sa_prop_list where prop_type_id='mr_sect_attr' and prop_list_id=y.mr_sect_attr) 用电性质,
y.PLAN_MR_DATE 计划抄表日期,
y.send_date 发行日期,
x.build_date 建档日期,
z.ogr_name kkk,
(select prop_list_name from epm_ln.sa_prop_list where prop_type_id='mr_mode' and prop_list_id=y.mr_mode_code) 抄表方式,
(select -- b.cons_no 用户编号,
nvl(b.prepay_bal,0)-(nvl(sum(a.rcvbl_amt-a.rcved_amt)+sum(a.rcvbl_penalty-a.rcved_penalty),0))
from epm_ln.a_rcvbl_flow a
right join epm_ln.a_acct_bal b on a.cons_no=b.cons_no
where b.org_no like '21402%'
and b.cons_no=x.cons_no group by b.cons_no,b.prepay_bal) 用户余额,
x.mr_sect_no
from epm_ln.c_cons x, epm_ln.r_plan y ,epsa_ln.sa_org
where x.mr_sect_no=y.mr_sect_no and x.org_no like '21402%'
and z.org_no=y.org_no
and y.amt_ym='201803'
and y.plan_status='08'
and x.status_code<>'9'
and y.org_no like '21402%'
and y.mr_sect_attr not in ('00')
--- and y.mr_sect_no='8007980422'
and to_char(y.send_date,'yyyy-mm-dd')='2018-03-06'
union all
select cons_no,
(select prop_list_name from epm_ln.sa_prop_list where prop_type_id='plan_status' and prop_list_id=y.plan_status) 当前计划状态,
(select prop_list_name from epm_ln.sa_prop_list where prop_type_id='mr_sect_attr' and prop_list_id=y.mr_sect_attr) 用电性质,
y.PLAN_MR_DATE 计划抄表日期,
y.send_date 发行日期,
x.build_date 建档日期,
z.ogr_name kkk ,
(select prop_list_name from epm_ln.sa_prop_list where prop_type_id='mr_mode' and prop_list_id=y.mr_mode_code) 抄表方式,
(select -- b.cons_no 用户编号,
nvl(b.prepay_bal,0)-(nvl(sum(a.rcvbl_amt-a.rcved_amt)+sum(a.rcvbl_penalty-a.rcved_penalty),0))
from epm_ln.a_rcvbl_flow a
right join epm_ln.a_acct_bal b on a.cons_no=b.cons_no
where b.org_no like '21402%'
and b.cons_no=x.cons_no group by b.cons_no,b.prepay_bal) 用户余额,
x.mr_sect_no
from epm_ln.c_cons x, epm_ln.arc_r_plan y ,epsa_ln.sa_org z
where x.mr_sect_no=y.mr_sect_no and x.org_no like '21402%'
and z.org_no=y.org_no
and y.amt_ym='201803'
and y.plan_status='08'
and x.status_code<>'9'
and y.org_no like '21402%'
and y.mr_sect_attr not in ('00')
--- and y.mr_sect_no='8007980422'
and to_char(y.send_date,'yyyy-mm-dd')='2018-03-06'
) where nvl(用户余额,0)< 0
group by kkk