SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE   VIEW [load].[Service_gesamt] AS

SELECT [Client_DB]
     --, [Beleg_ID]
     , [Department Code]
     , [Service Order No]
     , [Gen Prod Posting Group]
     , [Serviceberater]
	 , [User Id]
     , [Hauptbetrieb]
     , [Standort]
     , [Umsatzart]
     , [Fabrikat]
     , [Model]
     , [Fahrzeug]
     , [Marke]
     , [Auftragsart]
     , [Kundenart]
     , [Kunde]
     , [Umsatz Lohn]
     , [Umsatz Teile Service]
     , [Einsatz Teile Service]
     , [Invoice Date]
     , [Order Number]
     , [Order Number_Rg_Ausg]
     , 0.0 AS [ben. AW_Time_Clock]
     , [verk Std]
     , [DG]
     , [Auftragsposition]
     , [SB_Gruppe]
     , [Rabatt Lohn]
     , [Rabatt Teile]
     , [Order_Desc_100]
     , [Invoice_Desc_100]
     , [TÜV_Amount]
     , [FL_Lack_Amount]
     , [Mietw_Amount]
     , [Umsatz_Sonst_Rest]
	 , [No]
	 , [Labor No]
	 , [Position]
	 , [Kunde_Verkaufskunde]
	 , [Make Code]
	 ,[Location Code]
	 , [Amount]
	 , [Line Discount Amount]
	 , [Quantity]
	 , [Unit Cost (lcy)]
	 , 'RG' AS [Source Table]
FROM [transform].[Service_Ausgangsrechnung_ab_2011_SLE_ims_ohne_SLE]

/*
UNION ALL

SELECT [Client_DB]
     --, [Beleg_ID]
     , [Department Code]
     , [Service Order No]
     , [Gen Prod Posting Group]
     , [Serviceberater]
     , [Hauptbetrieb]
     , [Standort]
     , [Umsatzart]
     , [Fabrikat]
     , [Model]
     , [Fahrzeug]
     , [Marke]
     , [Auftragsart]
     , [Kundenart]
     , [Kunde]
     , 0.0 AS [Umsatz Lohn]
     , 0.0 AS [Umsatz Teile Service]
     , 0.0 AS [Einsatz Teile Service]
     , [Invoice Date]
     , [Order Number]
     , [Order Number_Rg_Ausg]
     , [ben. AW_Time_Clock]
     , 0.0 AS [verk Std]
     , 0 AS [DG]
     , [Auftragsposition]
     , [SB_Gruppe]
     , 0.0 AS [Rabatt Lohn]
     , 0.0 AS [Rabatt Teile]
     , '' AS [Order_Desc_100]
     , '' AS [Invoice_Desc_100]
     , 0.0 AS [TÜV_Amount]
     , 0.0 AS [FL_Lack_Amount]
     , 0.0 AS [Mietw_Amount]
     , 0.0 AS [Umsatz_Sonst_Rest]
	 , [No]
	 , '' AS [Labor No]
	 , [Position]
	 , [Kunde_Verkaufskunde]
	 , [Make Code]
	 ,[Location Code]
	 , 0 AS [Amount]
	 , 0 AS [Line Discount Amount]
	 , 0 AS [Quantity]
	 , 0 AS [Unit Cost (lcy)]
	 , 'RG_ben_AW' AS [Source Table]
FROM [transform].[Service_Ausgangsrechnung_ab_2011_ben_AW_final]
*/
UNION ALL

SELECT [Client_DB]
     --, [Beleg_ID]
     , [Department Code]
     , [Service Order No_ohne_Einschränkung] AS [Service Order No]
     , [Gen Prod Posting Group]
     , [Serviceberater]
	 , [User Id]
     , [Hauptbetrieb]
     , [Standort]
     , [Umsatzart]
     , [Fabrikat]
     , [Model]
     , [Fahrzeug]
     , [Marke]
     , [Auftragsart]
     , [Kundenart]
     , [Kunde]
     , [Umsatz Lohn]
     , [Umsatz Teile Service]
     , [Einsatz Teile Service]
     , [Invoice Date]
     , [Order Number]
     , [Order Number_Rg_Ausg]
     , 0.0 AS [ben. AW_Time_Clock]
     , [verk Std]
     , [DG]
     , [Auftragsposition]
     , [SB_Gruppe]
     , [Rabatt Lohn]
     , [Rabatt Teile]
     , [Order_Desc_100]
     , [Invoice_Desc_100]
     , [TÜV_Amount]
     , [FL_Lack_Amount]
     , [Mietw_Amount]
     , [Umsatz_Sonst_Rest]
	 , [No]
	 , '' [Labor No]
	 , '' AS [Position]
	 , [Kunde_Verkaufskunde]
	 , [Make Code]
	 ,[Location Code]
	 , [Amount]
	 , [Line Discount Amount]
	 , [Quantity]
	 , [Unit Cost (lcy)]
	 , 'GS' AS [Source Table]
	 FROM [transform].[Service_Gutschriften_ab_2011]
/*
UNION ALL

SELECT [Client_DB]
     --, [Beleg_ID]
     , [Department Code]
     , [Service Order No]
     , [Gen Prod Posting Group]
     , [Serviceberater]
     , [Hauptbetrieb]
     , [Standort]
     , [Umsatzart]
     , [Fabrikat]
     , [Model]
     , [Fahrzeug]
     , [Marke]
     , [Auftragsart]
     , [Kundenart]
     , [Kunde]
     , 0.0 AS [Umsatz Lohn]
     , 0.0 AS [Umsatz Teile Service]
     , 0.0 AS [Einsatz Teile Service]
     , [Invoice Date]
     , [Order Number]
     , [Order Number_Rg_Ausg]
     , [ben. AW_Time_Clock]
     , 0.0 AS [verk Std]
     , 0 AS [DG]
     , [Auftragsposition]
     , [SB_Gruppe]
     , 0.0 AS [Rabatt Lohn]
     , 0.0 AS [Rabatt Teile]
     , [Order_Desc_100]
     , [Invoice_Desc_100]
     , 0.0 AS [TÜV_Amount]
     , 0.0 AS [FL_Lack_Amount]
     , 0.0 AS [Mietw_Amount]
     , 0.0 AS [Umsatz_Sonst_Rest]
	 , [No]
	 , '' AS [Labor No]
	 , [Position]
	 , [Kunde_Verkaufskunde]
	 , [Make Code]
	 ,[Location Code]
	 , 0 AS [Amount]
	 , 0 AS [Line Discount Amount]
	 , 0 AS [Quantity]
	 , 0 AS [Unit Cost (lcy)]
	 , 'GS_ben_AW' AS [Source Table]
FROM [transform].[Service_Gutschriften_ab_2011_ben_AW_final]

*/
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
