- 论坛徽章:
- 0
|
本帖最后由 qq3632 于 2014-01-24 01:16 编辑
sql语句多次关联自身,如何优化,各位帮帮忙看下
sql如下:
select b.phone_no,c.channel_name,decode(b.run_code,'A','有效','无效') run_code,
(select d.logic_data from dchncustmsgdet20131201 d where d.attr_id='100000047' and d.id_no = b.id_no) main_this_tc,
(select d.logic_data from dchncustmsgdet20131201 d where d.attr_id='1200000023' and d.id_no = b.id_no) main_last_tc,
(select d.logic_data from dchncustmsgdet20131201 d where d.attr_id='100000049' and d.id_no = b.id_no) bonus_blnc,
(select d.logic_data from dchncustmsgdet20131201 d where d.attr_id='100000033' and d.id_no = b.id_no) convert_type,
(select e.logic_data from dchncustdatadet20131201 e where e.attr_id ='100000109' and e.id_no = b.id_no) innet_store
from dchncustmsg20131201 b,channel c ,CHANNEL_TYPE_CONFIG d
where b.chnorgunit_id = c.channel_id
and c.CHANNEL_TYPE_CD = d.CHANNEL_TYPE_ID;
执行计划如下:
|
|