谁能给优化一下下面的语句,不胜感激,特别是xzpm_user_v表用了3个别名
select decode('0', '0', to_char(rownum), '0' || '.' || rownum) NO, t.*
from (select decode(substr(n.check_point_type, -1, 1),
'3',
'THREE',
'2',
'TWO') CHECK_LEVEL,
n.PLAN_END_PEOPLE,
n.ACTUAL_START_PEOPLE,
xuv1.USER_NAME PLAN_START_PEOPLE_NAME,
xuv2.USER_NAME PLAN_END_PEOPLE_NAME,
xuv3.USER_NAME ACTUAL_START_PEOPLE_NAME,
nvl(n.parent_struct_id, 0) parent_struct_id,
p.property_name CHECK_LEVEL_NAME,
r.property_name CHECK_type_name,
s.property_name ITEM_TYPE_NAME,
decode(n.attribute5,
null,
xuv1.USER_NAME || ' ' ||
to_char(n.PLAN_START_TIME, 'yyyy-mm-dd'),
'作废' || n.attribute5 || ' ' || n.attribute7) SPLAN_START_TIME,
decode(n.attribute5,
null,
xuv2.USER_NAME || ' ' ||
to_char(n.PLAN_END_TIME, 'yyyy-mm-dd'),
'作废' || n.attribute5 || ' ' || n.attribute7) SPLAN_END_TIME,
decode(n.attribute5,
null,
xuv3.USER_NAME || ' ' ||
to_char(n.ACTUAL_START_TIME, 'yyyy-mm-dd'),
'作废' || n.attribute5 || ' ' || n.attribute7) SACTUAL_START_TIME,
to_char(n.ACTUAL_END_TIME, 'yyyy-mm-dd') SACTUAL_END_TIME,
M.PROPERTY_NAME MAJOR_NAME
from xzpm_zds_opcheck_main n,
(select *
from xzpm_property_instance
where property_type_code = 'CPLEVEL') p,
(select *
from xzpm_property_instance
where property_type_code = 'CPTYPE') r,
(select *
from xzpm_property_instance
where property_type_code = 'ITEMTYPE') S,
(select *
from xzpm_property_instance
where property_type_code = 'EQUSYSTEM') M,
xzpm_user_v xuv1,
xzpm_user_v xuv2,
xzpm_user_v xuv3 where nvl(n.parent_struct_id, 0) = 0
and decode(substr(n.check_point_type, -1, 1),
'3',
'THREE',
'2',
'TWO') = p.property_scode(+)
and upper(substr(n.check_point_type, 1, 1)) = r.property_scode(+)
and n.ITEM_TYPE = S.property_scode(+)
AND N.CHECK_MAJOR = M.PROPERTY_SCODE(+)
and N.PLAN_START_PEOPLE = xuv1.USER_CODE(+)
and N.PLAN_END_PEOPLE = xuv2.USER_CODE(+)
and N.ACTUAL_START_PEOPLE = xuv3.USER_CODE(+)
order by sort_num) t |
|