SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE VIEW [test].[NW_GW_VK_V03] AS
SELECT format([Invoice_Date], 'yyyy-MM') AS [Periode]
     , [Verkäufer]
     , sum(try_convert(decimal(28, 8), replace([Menge], ',', '.'))) AS [Menge]
     , sum([Gesamterlöse]) AS [Erlös_FZG]
     , sum([Einsatz_Gesamt]) AS [Einsatz_FZG]
     , sum([Erlös_Prov_]) AS [Erlös_Prov_]
     , avg(try_convert(decimal(28, 8), [Standtage])) AS [Standtage]

FROM [transform].[NW_GW_VK]
WHERE [Invoice_Date] >= datefromparts(year(getdate()), 1, 1)
GROUP BY format([Invoice_Date], 'yyyy-MM'), [Verkäufer]
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
