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遍。是否有更优办法?
相关推荐
oraclemch 2020-11-06
Seandba 2020-08-16
dbasunny 2020-08-16
娜娜 2020-06-22
专注前端开发 2020-10-21
苏康申 2020-11-13
vitasfly 2020-11-12
liuyang000 2020-09-25
FellowYourHeart 2020-10-05
赵继业 2020-08-17
whyname 2020-08-16
拼命工作好好玩 2020-08-15
langyue 2020-08-15
写程序的赵童鞋 2020-08-03
Accpcjg 2020-08-02
tydldd 2020-07-30
好记忆也需烂 2020-07-28