oracle 多表子查询

oracle中8表子查询:

select mpp.prosmname,max(mpp.modulename),max(mpp.plantime),max(mpp.ctaskbd),max(mpp.maxEdate),max(mpp.examdetail) from (
select 
      (select (select op.prosmname from oaproject op where op.proid=mo.proid) from oaprojectmodule mo where mo.moduleid=mp.moduleid) prosmname,
      (select mo.modulename from oaprojectmodule mo where mo.moduleid=mp.moduleid) modulename,
      (select c.bmname from code_pub c where c.id=mp.plantypeid) bmname,
      mp.plantime plantime,
      (select dis.ctaskbd from wpl_plandist dis where dis.dealman='000000000000038' and dis.pdid=mp.pdid) ctaskbd,
      (select (select max(to_char(repday,'yyyy-mm-dd HH24:mi:ss')) from wpl_process where distid=di.distid) from wpl_plandist di where di.dealman='000000000000038' and di.pdid=mp.pdid) maxEdate,
      (select (select ex.examdetail from wpl_detailexam ex where ex.distid=di.distid) from wpl_plandist di where di.dealman='000000000000038' and di.pdid=mp.pdid) examdetail
from (select d.pdid,d.moduleid,d.plantypeid,d.plantime from wpl_detail d 
      where d.pdid in(select dis.pdid from wpl_plandist dis where dis.dealman='000000000000038'))mp
) mpp
group by mpp.prosmname
;

已解决,但有个缺点就是:dis.dealman='000000000000038'这句写了3遍。是否有更优办法?

相关推荐