select m.aab01 ,m.aab03 ,m.aab04,
(select aaa02 from aaa_file aa where aa.aaa01=m.aab05) as lb ,
(select suM(to_number(aae12))from aae_file n where n.aae04 = m.aab01 group by aae04) as num,
(select max(aae15) from aae_file n where n.aae04 = m.aab01 ) as price,
(select suM(to_number(aae12)*to_number(aae15))from aae_file n here n.aae04 = m.aab01 group by aae04) as total
from aab_file m order by lb
(select aaa02 from aaa_file aa where aa.aaa01=m.aab05) as lb ,
(select suM(to_number(aae12))from aae_file n where n.aae04 = m.aab01 group by aae04) as num,
(select max(aae15) from aae_file n where n.aae04 = m.aab01 ) as price,
(select suM(to_number(aae12)*to_number(aae15))from aae_file n here n.aae04 = m.aab01 group by aae04) as total
from aab_file m order by lb
2、要优化,按1修改后,贴出执行计划。并说明每个表数据量及索引建立情况。
---b.aae04 = m.aab01 建立联合索引select m.aab01 ,m.aab03 ,m.aab04,num,price,total,
(case when m.aaa01=m.aab05 then aaa02 end) lb
from aab_file m,
(select suM(to_number(aae12)) num,max(aae15) price,suM(aae12*aae15) total from aae_file group by aae04) b
where b.aae04 = m.aab01