SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE VIEW [test].[OP_aus_LOC_Belege_gesamt_OP01] AS

SELECT [Standort_Name]
     , [Kostenstelle]
     , sum([offen]) AS [offen]
FROM (SELECT [Standort_Name]
           , [Kostenstelle]
           , convert(decimal(28, 8), [offen_]) AS [offen]
      FROM [transform].[OP_aus_LOC_Belege_8520]
      UNION ALL
      SELECT [Standort_Name]
           , [Kostenstelle]
           , convert(decimal(28, 8), [offen]) AS [offen]
      FROM [transform].[OP_aus_LOC_Belege_Deb_Saldo]
      UNION ALL
      SELECT [Standort_Name]
           , [Kostenstelle]
           , convert(decimal(28, 8), [offen]) AS [offen]
      FROM [transform].[OP_aus_LOC_Belege_nur_8520]
      WHERE [offen] <> ''
      UNION ALL
      SELECT [Standort_Name]
           , [Kostenstelle]
           , convert(decimal(28, 8), [offen]) AS [offen]
      FROM [transform].[OP_aus_LOC_Belege_ohne_8520]) [V1]
GROUP BY [Standort_Name], [Kostenstelle]
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
