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遍。是否有更優辦法?
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章