SET QUOTED_IDENTIFIER ON 
GO
SET ANSI_NULLS ON 
GO
CREATE   VIEW [transform].[current_date_Prognose_operativ_VJ]
AS
SELECT [Bundeslaender Id]
     , [Datum] as [Invoice Date]
     , [Wochentage Id]
     , [Arbeitstag Mofr]
     , [Zaehler Mofr]
     , [Summe Mofr]
     , [Arbeitstag Mosa]
     , [Zaehler Mosa]
     , [Summe Mosa]
     , [Feiertage Id]
     , [Jahr]
     , iif([Config].[mosa_operativ] = 'J', [Arbeitstag Nr Jahr Mosa], [Arbeitstag Nr Jahr Mofr]) AS "Arbeitstag Nr Jahr"
     , iif([Config].[mosa_operativ] = 'J', [Gesamt Arbeitstage Mosa], [Gesamt Arbeitstage Mofr]) AS "Gesamt Arbeitstage"
     , [Tag_Dashboard]
     , [Monat_Dashboard]
     , [Jahr_Dashboard]
FROM [transform_imr].[Arbeitstage]
         CROSS JOIN [data].[GC_Config_Pivot] [Config]
WHERE [Bundeslaender Id] = [Config].[bundeslaender_id]
  AND ([Arbeitstag Mofr] = 1 OR ([Config].[mosa_operativ] = 'J' AND [Arbeitstag Mosa] = 1) OR [Feiertage Id] = 23)
  AND ([Jahr] BETWEEN year(getdate()) - 2 AND year(getdate()))
GO
SET QUOTED_IDENTIFIER OFF 
GO
SET ANSI_NULLS OFF 
GO

GO
