SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE VIEW [test_systemvergleich].[Aftersales_S03] AS
SELECT coalesce(T1.Periode, T2.Periode) as Periode
     , coalesce(T1.Serviceberater, T2.Serviceberater) as Serviceberater
     , T1.Lohn      AS Lohn_Kunde
     , T2.Lohn      AS Lohn_ETL
     , T1.Teile     AS Teile_Kunde
     , T2.Teile     AS Teile_ETL
     , T1.Fremdl    AS Fremdl_Kunde
     , T2.Fremdl    AS Fremdl_ETL
     , T1.Mietwagen AS Mietwagen_Kunde
     , T2.Mietwagen AS Mietwagen_ETL
     , T1.ben_Std   AS ben_Std_Kunde
     , T2.ben_Std   AS ben_Std_ETL
     , T1.verk_Std  AS verk_Std_Kunde
     , T2.verk_Std  AS verk_Std_ETL
     , T1.DG        AS DG_Kunde
     , T2.DG        AS DG_ETL
FROM GC.test.Aftersales_S03 T1
         FULL OUTER JOIN test.Aftersales_S03 T2 ON
    T1.Periode = T2.Periode AND
    T1.Serviceberater = T2.Serviceberater
WHERE T1.[Lohn] is null OR T2.[Lohn] is null OR 
      round([T1].[Lohn] - [T2].[Lohn], 2) <> 0.00 OR 
    round([T1].[Teile] - [T2].[Teile], 2) <> 0.00 OR
    round([T1].[Fremdl] - [T2].[Fremdl], 2) <> 0.00 OR
    round([T1].[Mietwagen] - [T2].[Mietwagen], 2) <> 0.00 OR
    round([T1].[ben_Std] - [T2].[ben_Std], 2) <> 0.00 OR
    round([T1].[verk_Std] - [T2].[verk_Std], 2) <> 0.00 OR
    round([T1].[DG] - [T2].[DG], 2) <> 0.00
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
