update1

UPDATE COST_EVENT CE
   SET (CE.EQUIP_EVE_INV_ACT_HRS, CE.EQUIP_EVE_INV_ACT_STARTS, CE.EQUIP_EVE_INV_FFHRS, CE.EQUIP_EVE_INV_FFSTARTS) = (SELECT NVL(CE.EQUIP_CUM_ACT_HRS,
                                                                                                                                0) -
                                                                                                                            NVL(CEE.EQUIP_CUM_ACT_HRS,
                                                                                                                                0),
                                                                                                                            NVL(CE.EQUIP_CUM_ACT_STARTS,
                                                                                                                                0) -
                                                                                                                            NVL(CEE.EQUIP_CUM_ACT_STARTS,
                                                                                                                                0),
                                                                                                                            NVL(CE.EQUIP_CUM_FFHRS,
                                                                                                                                0) -
                                                                                                                            NVL(CEE.EQUIP_CUM_FFHRS,
                                                                                                                                0),
                                                                                                                            NVL(CE.EQUIP_CUM_FFSTARTS,
                                                                                                                                0) -
                                                                                                                            NVL(CEE.EQUIP_CUM_FFSTARTS,
                                                                                                                                0)
                                                                                                                       FROM COST_EVENT CEE
                                                                                                                      WHERE CEE.MDL_VER_ID =
                                                                                                                            CE.MDL_VER_ID
                                                                                                                        AND CEE.EQUIP_ID =
                                                                                                                            CE.EQUIP_ID
                                                                                                                        AND CEE.EVENT_START_DT =
                                                                                                                            DECODE((SELECT MAX(CCEE.EVENT_START_DT)
                                                                                                                                     FROM COST_EVENT CCEE
                                                                                                                                    WHERE CCEE.MDL_VER_ID =
                                                                                                                                          CE.MDL_VER_ID
                                                                                                                                      AND CCEE.EQUIP_ID =
                                                                                                                                          CE.EQUIP_ID
                                                                                                                                      AND CCEE.EVENT_START_DT <
                                                                                                                                          CE.EVENT_START_DT),
                                                                                                                                   NULL,
                                                                                                                                   (SELECT CCEE.EVENT_START_DT
                                                                                                                                      FROM COST_EVENT CCEE
                                                                                                                                     WHERE CCEE.MDL_VER_ID =
                                                                                                                                           CE.MDL_VER_ID
                                                                                                                                       AND CCEE.EQUIP_ID =
                                                                                                                                           CE.EQUIP_ID
                                                                                                                                       AND CCEE.EVENT_TYP_ID = 5),
                                                                                                                                   (SELECT MAX(CCEE.EVENT_START_DT)
                                                                                                                                      FROM COST_EVENT CCEE
                                                                                                                                     WHERE CCEE.MDL_VER_ID =
                                                                                                                                           CE.MDL_VER_ID
                                                                                                                                       AND CCEE.EQUIP_ID =
                                                                                                                                           CE.EQUIP_ID
                                                                                                                                       AND CCEE.EVENT_START_DT <
                                                                                                                                           CE.EVENT_START_DT))
                                                                                                                           -- EXCLUDE EOTC,EOTE,INIT,SERVICE,MOB,EOTS,UNPLAN SERVICE
                                                                                                                        AND CE.EVENT_TYP_ID NOT IN
                                                                                                                            (2, 9, 10, 11, 12))

 

你可能感兴趣的:(update)