1

嘿大家我是甲骨文的新手,我被这个声明击中了,我不知道正在发生什么样的加入,谁能帮助我?

这是我无法表达的声明。这是在做什么?内部联接?全外连接?右外连接?左外连接?

 AND TO_DATE(&&SYS_DT, 'DD-MON-YY') BETWEEN R.BEG_EFFECTIVE_DT(+) AND R.END_EFFECTIVE_DT(+)

这是代码片段:

          SELECT T.SUPPLY_ORDER_NBR,
      T.SUPPLY_ORDER_LINE_NBR,
      T.PART_ID,
      P.DESCRIPTION           PART_DESC,
      P.STD_TOTAL_COST,
      P.PART_TYPE,
      P.MAST_ID               INV_TYPE,
      S.REC_LOC,
      T.PLAN_SYS_ID,
      T.PLAN_SYS_ID_SOURCE_CD,
      Z.VENDOR_TERMS,
      X.ORACLE_NAME           SUPPLIER_NAME,
      X.EMR_VENDOR_NBR        SUPPLIER_ID,
      V.SUPPLIER_NAME         LEGACY_SUPPLIER_NAME,
      TRIM(S.SUPPLIER_ID)     LEGACY_SUPPLIER_ID,
      S.SO_UOM,
      S.SO_STATUS,
      SUBSTR(P.PUR_COMMODITY_CD, 1, 4)                                                       DRI_CODE,
      R.LEAD_TIME                                                                            SYSTEM_LEAD_TIME,
      R.SUPPLIER_UNIT_PRICE,
      R.PREFERRED_SUPPLIER_SW,
      S.BUYER_ID
      , NVL(DECODE(TRIM(T.PLAN_SYS_ID_SOURCE_CD)
      ,'CMB', 'MAY'
      ,'CMS', TRIM(T.TO_LOC_ID)
      ,'MCG', TRIM(T.TO_LOC_ID)
      ,'OMFG',NVL(TRIM(T.TO_ORG_CD), T.ORG_ID)
      ,NVL(TRIM(T.FROM_LOC_ID), TRIM(T.PLAN_SYS_ID_SOURCE_CD))
      ),    'BIO')                                          LOCATION
      , NVL(C.DESCRIPTION,'BUYOUT')                             PLANT_DESC
      , P.PLANT_OF_MFG,
      P.DIVISION_CD,
      P.PLANNER_ID,
      L.NOMAD_NAME                                                                           PIC_PLANNER_NAME,
      S.ORIG_ORD_QTY,
      S.OPEN_QTY,
      T.QTY_RECEIVED                                                                         QUANTITY_RECEIVED,
      DECODE(TRIM(S.PLAN_SYS_ID_SOURCE_CD), 'OMFG', S.NEED_BY_DT, S.PROM_DT)                 REQUIRED_DATE,
      S.ENTRY_DT                                                                             DATE_ORDERED,
      T.EARLY_DAYS_COUNT,
      T.EARLY_DAYS_QTY,
      T.EARLY_DAYS_STD_CST,
      T.ON_TIME_DAYS_COUNT,
      T.ON_TIME_DAYS_QTY,
      T.ON_TIME_DAYS_STD_CST,
      T.LATE_TIME_DAYS_COUNT,
      T.LATE_TIME_DAYS_QTY,
      T.LATE_TIME_DAYS_STD_CST,
      T.EARLY_DAYS_QTY + T.ON_TIME_DAYS_QTY + T.LATE_TIME_DAYS_QTY              TOTAL_INV_RECEIPTS_QTY,
      T.EARLY_DAYS_STD_CST + T.ON_TIME_DAYS_STD_CST + T.LATE_TIME_DAYS_STD_CST               TOTAL_INV_RECEIPTS_AT_CST,
      T.BEG_RECEIVE_DATE                                                                     BEG_RECEIVE_DATE,
      T.LAST_RECEIVE_DATE                                                                    DATE_RECEIVED,
      T.LAST_RECEIVE_DATE-S.ENTRY_DT                                                         DURATION_DAYS,
      S.PURCHASE_PRICE,
      P.ORG_ID,
      T.LATE_DAYS,
      T.EARLY_DAYS
    FROM MDW.SUPPLY_ORDER31      S,
      MDW.PLANNER31           L,
      MDW.PART31              P,
      MDW.SUPPLIER_PART31     R,
      MDW.SUPPLIER31          V,
      MDW.SUPPLIER_XREF       X,
      MDW.LOCATION            C,
      (
       SELECT MIN(VENDOR_TERMS)     VENDOR_TERMS,
              PLAN_SYS_ID,
              ORACLE_NAME,
              EMR_VENDOR_NBR
         FROM MDW.SUPPLIER_XREF
     GROUP BY EMR_VENDOR_NBR,
              ORACLE_NAME,
              PLAN_SYS_ID
      )                       Z,
      (
       SELECT SUPPLY_ORDER_NBR,
              SUPPLY_ORDER_LINE_NBR,
              SO_SHIPMENT,
              PART_ID,
              PLAN_SYS_ID,
              ORG_ID,
              PLAN_SYS_ID_SOURCE_CD,
              TO_LOC_ID,
              FROM_LOC_ID,
              TO_ORG_CD,
              NVL(SUM(EARLY_DAYS_COUNT), 0)         EARLY_DAYS_COUNT,
              NVL(SUM(EARLY_DAYS_QTY), 0)           EARLY_DAYS_QTY,
              NVL(SUM(EARLY_DAYS_STD_CST), 0)       EARLY_DAYS_STD_CST,
              NVL(SUM(ON_TIME_DAYS_COUNT), 0)       ON_TIME_DAYS_COUNT,
              NVL(SUM(ON_TIME_DAYS_QTY), 0)         ON_TIME_DAYS_QTY,
              NVL(SUM(ON_TIME_DAYS_STD_CST), 0)     ON_TIME_DAYS_STD_CST,
              NVL(SUM(LATE_DAYS_COUNT), 0)          LATE_TIME_DAYS_COUNT,
              NVL(SUM(LATE_DAYS_QTY), 0)            LATE_TIME_DAYS_QTY,
              NVL(SUM(LATE_DAYS_STD_CST), 0)        LATE_TIME_DAYS_STD_CST,
              NVL(SUM(LATE_DAYS), 0)                LATE_DAYS,
               NVL(SUM(EARLY_DAYS), 0)              EARLY_DAYS,
              TRANS_DT                              LAST_RECEIVE_DATE,
              TRANS_DT                              BEG_RECEIVE_DATE,
              NVL(SUM(QTY_RECEIVED), 0)             QTY_RECEIVED
         FROM (
               SELECT SUPPLY_ORDER_NBR,
                      SUPPLY_ORDER_LINE_NBR,
                      SO_SHIPMENT,
                      PART_ID,
                      PLAN_SYS_ID,
                      ORG_ID,
                      PLAN_SYS_ID_SOURCE_CD,
                      TRANS_DT,
                      TO_LOC_ID,
                      FROM_LOC_ID,
                      TO_ORG_CD,
                      CASE
                         WHEN DT_DAYS > DAYS_EARLY AND DT_DIF > 0
                         THEN SUM(1)
                      END                                                         EARLY_DAYS_COUNT,
                      CASE
                         WHEN DT_DAYS > DAYS_EARLY AND DT_DIF > 0
                         THEN SUM(INV_QTY)
                      END                                                         EARLY_DAYS_QTY,
                      CASE
                         WHEN DT_DAYS > DAYS_EARLY AND DT_DIF > 0
                         THEN SUM(EXT_TRANS_COST)
                      END                                                         EARLY_DAYS_STD_CST,
                      CASE
                         WHEN DT_DAYS <= DAYS_LATE AND DT_DIF < 0
                         THEN SUM(1)
                         WHEN DT_DAYS <= DAYS_EARLY AND DT_DIF > 0
                         THEN SUM(1)
                         WHEN DT_DIF = 0
                         THEN SUM(1)
                      END                                                         ON_TIME_DAYS_COUNT,
                      CASE
                         WHEN DT_DAYS <= DAYS_LATE AND DT_DIF < 0
                         THEN SUM(INV_QTY)
                         WHEN DT_DAYS <= DAYS_EARLY AND DT_DIF > 0
                         THEN SUM(INV_QTY)
                         WHEN DT_DIF = 0
                         THEN SUM(INV_QTY)
                      END                                                         ON_TIME_DAYS_QTY,
                      CASE
                         WHEN DT_DAYS <= DAYS_LATE AND DT_DIF < 0
                         THEN SUM(EXT_TRANS_COST)
                         WHEN DT_DAYS <= DAYS_EARLY AND DT_DIF > 0
                         THEN SUM(EXT_TRANS_COST)
                         WHEN DT_DIF = 0
                         THEN SUM(EXT_TRANS_COST)
                      END                                                         ON_TIME_DAYS_STD_CST,
                      CASE
                         WHEN DT_DAYS > DAYS_LATE AND DT_DIF < 0
                         THEN SUM(1)
                      END                                                         LATE_DAYS_COUNT,
                      CASE
                         WHEN DT_DAYS > DAYS_LATE AND DT_DIF < 0
                         THEN SUM(INV_QTY)
                      END                                                         LATE_DAYS_QTY,
                      CASE
                         WHEN DT_DAYS > DAYS_LATE AND DT_DIF < 0
                         THEN SUM(EXT_TRANS_COST)
                      END                                                         LATE_DAYS_STD_CST,
                  CASE
                    WHEN DT_DIF < 0 THEN DT_DAYS
                                            ELSE 0
                  END                               LATE_DAYS,
                  CASE
                    WHEN DT_DIF > 0 THEN DT_DAYS                        -- modified by MDESPHY to correct on-time, early and late list
                    ELSE 0
                  END                               EARLY_DAYS
                  , SUM(INV_QTY)                            QTY_RECEIVED
                 FROM (
                       SELECT SUPPLY_ORDER_NBR,
                              SUPPLY_ORDER_LINE_NBR,
                              SO_SHIPMENT,
                              PART_ID,
                              PLAN_SYS_ID,
                              ORG_ID,
                              PLAN_SYS_ID_SOURCE_CD,
                              TRANS_DT,
                              TO_LOC_ID,
                              FROM_LOC_ID,
                              TO_ORG_CD,
                              ABS(DT_DIF - 2 * FLOOR(DT_DIF/7) - DECODE(PDWD, 1, 1, 0) + DECODE(TDWD, 1, 1, 0) -
                                 DECODE(PDWD, 1, 0, DECODE(TDWD, 1, 0, CASE WHEN PDWD < TDWD THEN 2 ELSE 0  END)) -
                                 DECODE(PDWD, 1, 0, DECODE(TDWD, 1, 2, 0)))     DT_DAYS,
                              DT_DIF,                               -- added by MDESPHY
                              EXT_TRANS_COST,
                              INV_QTY,
                              DAYS_EARLY,
                              DAYS_LATE
                         FROM (
                               SELECT I.SUPPLY_ORDER_NBR,
                                      I.SUPPLY_ORDER_LINE_NBR,
                                      O.SO_SHIPMENT,
                                      I.PART_ID,
                                      I.PLAN_SYS_ID,
                                      I.ORG_ID,
                                      I.PLAN_SYS_ID_SOURCE_CD,
                                      MAX(I.TRANS_DT)                                                                                     TRANS_DT,
                                      I.TO_LOC_ID,
                                      I.FROM_LOC_ID,
                                      NVL(I.TO_ORG_CD,' ')                                                                                TO_ORG_CD,
                                      DECODE(TRIM(O.PLAN_SYS_ID_SOURCE_CD), 'OMFG', O.NEED_BY_DT, O.PROM_DT)                              PROM_DT,
                                      DECODE(TRIM(O.PLAN_SYS_ID_SOURCE_CD), 'OMFG', O.NEED_BY_DT, O.PROM_DT) - MAX(I.TRANS_DT)            DT_DIF,
                                      TO_NUMBER(TO_CHAR(MAX(I.TRANS_DT), 'D'))                                                            TDWD,
                                      TO_NUMBER(TO_CHAR(DECODE(TRIM(O.PLAN_SYS_ID_SOURCE_CD), 'OMFG', O.NEED_BY_DT, O.PROM_DT), 'D'))     PDWD,
                                      SUM(I.EXT_TRANS_COST)                                         EXT_TRANS_COST,
                                      SUM(I.INV_QTY)                                                                                      INV_QTY,
                                      R.DAYS_EARLY,
                                      R.DAYS_LATE
                                 FROM MDW.SUPPLY_ORDER31    O,
                                      MDW.INV_TRANS     I,
                                      MDW.SUPPLIER_XREF X,
                                      MDW.SCORECARD_RANGE   R
                                WHERE O.SO_TYPE = 'PO'
                                  AND O.ENTRY_DT > TO_DATE('01-OCT-' || TO_CHAR(ADD_MONTHS(&&SYS_DT, -21), 'YY'), 'DD-MON-YY')
                                  AND O.SO_NBR = I.SUPPLY_ORDER_NBR
                                  AND O.SO_LINE_NBR = I.SUPPLY_ORDER_LINE_NBR
                                  AND O.SO_SHIPMENT = NVL(TO_NUMBER(TRIM(I.ORA_SHIP_NBR), '99'), 0)
                               -- AND O.SO_SHIPMENT = TO_NUMBER(NVL(ORA_SHIP_NBR, 0), '999')
                                  AND O.PART_ID = I.PART_ID
                                  AND O.PLAN_SYS_ID = I.PLAN_SYS_ID
                                  AND O.ORG_ID = I.ORG_ID
                                  AND O.PLAN_SYS_ID_SOURCE_CD = I.PLAN_SYS_ID_SOURCE_CD
                                  AND I.PLAN_SYS_ID_SOURCE_CD != 'NOMD'
                                  AND I.SUPPLIER_ID IS NOT NULL
                                  AND I.TRANS_TYPE = 'R'
                                  AND I.TRANS_CD NOT IN ('PORADJ','PORRTV')
                                  AND I.INV_QTY != 0
                                  AND I.LOAD_DT < TO_DATE(&&SYS_DT, 'DD-MON-YY') + 1
                                  AND I.SUPPLIER_ID = X.SUPPLIER_ID
                                  AND I.PLAN_SYS_ID_SOURCE_CD = X.PLAN_SYS_ID           -- added by mdesphy to eliminate doubled qty
                                  AND X.EMR_VENDOR_NBR = R.SUPPLIER_ID
                             GROUP BY I.SUPPLY_ORDER_NBR,
                                      I.SUPPLY_ORDER_LINE_NBR,
                                      O.SO_SHIPMENT,
                                      I.PART_ID,
                                      I.PLAN_SYS_ID,
                                      I.ORG_ID,
                                      I.PLAN_SYS_ID_SOURCE_CD,
                                   -- I.TRANS_DT,
                                      I.TO_LOC_ID,
                                      I.FROM_LOC_ID,
                                      I.TO_ORG_CD,
                                   -- NVL(I.TO_ORG_CD),
                                      DECODE(TRIM(O.PLAN_SYS_ID_SOURCE_CD), 'OMFG', O.NEED_BY_DT, O.PROM_DT),
                                      R.DAYS_EARLY,
                                      R.DAYS_LATE
                              )
                      )
             GROUP BY SUPPLY_ORDER_NBR,
                      SUPPLY_ORDER_LINE_NBR,
                      SO_SHIPMENT,
                      PART_ID,
                      PLAN_SYS_ID,
                      ORG_ID,
                      PLAN_SYS_ID_SOURCE_CD,
                      TRANS_DT,
                      TO_LOC_ID,
                      FROM_LOC_ID,
                      TO_ORG_CD,
                      DT_DIF,
                      DT_DAYS,
                      DAYS_EARLY,
                      DAYS_LATE
              )
     GROUP BY SUPPLY_ORDER_NBR,
              SUPPLY_ORDER_LINE_NBR,
              SO_SHIPMENT,
              PART_ID,
              PLAN_SYS_ID,
              ORG_ID,
              PLAN_SYS_ID_SOURCE_CD,
              TRANS_DT,
              TO_LOC_ID,
              FROM_LOC_ID,
              TO_ORG_CD
       )            T
 WHERE T.SUPPLY_ORDER_NBR = S.SO_NBR
   AND T.SUPPLY_ORDER_LINE_NBR = S.SO_LINE_NBR
   AND T.SO_SHIPMENT = S.SO_SHIPMENT
   AND T.PART_ID = S.PART_ID
   AND T.PLAN_SYS_ID = S.PLAN_SYS_ID
   AND T.PLAN_SYS_ID_SOURCE_CD = S.PLAN_SYS_ID_SOURCE_CD
   AND T.PART_ID = P.PART_ID
   AND T.PLAN_SYS_ID = P.PLAN_SYS_ID
   AND T.ORG_ID = P.ORG_ID
   AND TRIM(C.LOCATION(+)) = NVL(DECODE(TRIM(T.PLAN_SYS_ID_SOURCE_CD),'CMB', 'MAY'
                                                                       ,'CMS', TRIM(T.TO_LOC_ID)
                                                                     ,'MCG', TRIM(T.TO_LOC_ID)
                                                                     ,'OMFG',NVL(TRIM(T.TO_ORG_CD), T.ORG_ID)
                                                    ,NVL(TRIM(T.FROM_LOC_ID), TRIM(T.PLAN_SYS_ID_SOURCE_CD))),  'BIO')
   AND X.PLAN_SYS_ID = Z.PLAN_SYS_ID
   AND X.ORACLE_NAME = Z.ORACLE_NAME
   AND X.EMR_VENDOR_NBR = Z.EMR_VENDOR_NBR
   AND TRIM(V.SUPPLIER_ID) = TRIM(X.SUPPLIER_ID)
   AND X.PLAN_SYS_ID = V.PLAN_SYS_ID
   AND TRIM(S.SUPPLIER_ID) = TRIM(V.SUPPLIER_ID)
-- AND S.PLAN_SYS_ID = V.PLAN_SYS_ID
   AND S.PLAN_SYS_ID_SOURCE_CD = V.PLAN_SYS_ID
-- AND (V.SUPPLIER_ID != '000079' AND V.PLAN_SYS_ID != 'CMB')
   AND S.PLAN_SYS_ID_SOURCE_CD != 'NOMD'
   AND P.PLANNER_ID = L.PLANNER_ID(+)
   AND TRIM(S.SUPPLIER_ID) = TRIM(R.SUPPLIER_ID(+))
   AND S.PART_ID = R.PART_ID(+)
   AND S.PLAN_SYS_ID = R.PLAN_SYS_ID(+)
   AND TO_DATE(&&SYS_DT, 'DD-MON-YY') BETWEEN R.BEG_EFFECTIVE_DT(+) AND R.END_EFFECTIVE_DT(+)
   AND S.ENTRY_DT > TO_DATE('01-OCT-' || TO_CHAR(ADD_MONTHS(&&SYS_DT,-21), 'YY'), 'DD-MON-YY')
4

1 回答 1

0

这是过时的 OracleOUTER JOIN表示法。

这个WHERE条件:

AND TO_DATE(&&SYS_DT, 'DD-MON-YY') BETWEEN R.BEG_EFFECTIVE_DT(+) AND R.END_EFFECTIVE_DT(+)

相当于

LEFT JOIN
        r
ON      TO_DATE(&&SYS_DT, 'DD-MON-YY') BETWEEN R.BEG_EFFECTIVE_DT AND R.END_EFFECTIVE_DT
于 2013-09-19T13:32:19.090 回答