CREATE OR REPLACE FORCE VIEW "V_DT430_DT472" ("DATUM_KAL", "PR", "VG", "RESS",
  "KOA", "OE_RESS", "DATE_CREATION", "DATE_MODIFY", "RWDU", "USER_CREATION",
  "USER_MODIFY", "OWNER_LICENSE", "OSC", "OWNER", "group", "any", "BEL_IST", 
  "POS", "ABR_DATUM", "SAP_STATE") AS 
  SELECT DATUM_KAL,
    PR,
    VG,
    RESS,
    KoA,
    OE_RESS,
    date_creation,
    date_modify,
    rwdu,
    user_creation,
    user_modify,
    owner_license,
    osc,
    owner,
    "group",
    "any",
    BEL_Ist,
    Pos,
    ABR_DATUM,
    SAP_STATE
  FROM
    (SELECT DATUM_KAL AS DATUM_KAL,
      DI001390        AS PR,
      DI001391        AS VG,
      DI001392        AS RESS,
      DI001393        AS KoA,
      DI009063        AS OE_RESS,
      DI001401        AS date_creation,
      DI001402        AS date_modify,
      DI001403        AS rwdu,
      DI001404        AS user_creation,
      DI001405        AS user_modify,
      DI001406        AS owner_license,
      DI000596        AS osc,
      DI001407        AS owner,
      DI001408        AS "group",
      DI001409        AS "any",
      (SELECT NVL(SUM(NVL(DI001510,0)),0) bel_ist_472
      FROM DT472
      WHERE DI001519 = DATUM_KAL
      AND DI001395   = DI001390
      AND DI001516   = DI001391
      AND DI001517   = DI001392
      ) BEL_Ist,
      (SELECT NVL(MAX(NVL(DI001400,0)),0) pos_472
      FROM DT472
      WHERE DI001519 = DATUM_KAL
      AND DI001395   = DI001390
      AND DI001516   = DI001391
      AND DI001517   = DI001392
      ) Pos,
      (SELECT NVL(MAX(NVL(DI002673,TO_DATE('01.01.1970', 'DD.MM.YYYY'))),
       TO_DATE('01.01.1970', 'DD.MM.YYYY')) ABR_DATUM
      FROM DT472
      WHERE DI001519 = DATUM_KAL
      AND DI001395   = DI001390
      AND DI001516   = DI001391
      AND DI001517   = DI001392
      ) ABR_DATUM,
      (SELECT NVL(MAX(NVL(SAP_STATE,0)),0) SAP_STATE
      FROM DT472
      WHERE DI001519 = DATUM_KAL
      AND DI001395   = DI001390
      AND DI001516   = DI001391
      AND DI001517   = DI001392
      ) SAP_STATE
    FROM DT466
    INNER JOIN dt461
    ON (DT461.DI001001 = DT466.DI001390
    AND DT461.DI001042 = 1)
    FULL OUTER JOIN
      (SELECT TRUNC(add_months(TO_DATE(TO_CHAR(sysdate, 'DD.MM.YYYY'), 'DD.MM.YYYY'),-24)) + INTERVAL '1' DAY * rownum DATUM_KAL
      FROM DT354
        CONNECT BY LEVEL <= 2*366
      ) KAL
    ON di001422 = to_date('01.01.1970', 'DD.MM.YYYY')
    );
