日期:2014-05-17  浏览次数:20899 次

有关左链接与子查询的疑惑(求助)
做项目忙了一天,头昏脑胀,求助下大家帮忙看下两段SQL

Oracle 10G 版本

第一段

select ebpoE.zbthnr as zbthnr1,ebpoE.Zqgdh,
        o.zbthnr2,
       ebpoE.ebeln,
       ebpoE.ebelp from t_sap_eban ebpoE
               
       left join (     
       select eban.banfn,eban.bnfpo,decode(nvl(ekpo.ebeln_pre, ''),
                           '',
                           (select eb.zbthnr
                              from t_sap_eban eb
                             where eb.ebeln || '-' || eb.ebelp =
                                   ekpo.konnr || '-' || ekpo.ktpnr
                                    and 
                                    eb.loekz is null  and rownum =1),
                           (select eb.zbthnr
                              from t_sap_eban eb
                             where eb.ebeln || '-' || eb.ebelp =
                                   ekpo.ebeln_pre || '-' || ekpo.ebelp_pre
                                   and 
                                    eb.loekz is null and rownum =1)) as zbthnr2
               from t_sap_eban eban, t_sap_ekpo ekpo
      &