(Sorry, I couldn\'t think of a better title)
I have created the following select statement (SQL Server) to work as a view.
SELECT DISTINCT
dbo.E
If you move your case
statement into the join, it should work.
Change
dbo.MyTable ON dbo.ECB.Date = dbo.MyTable.CutoffDate
To
dbo.Mytable ON dbo.ECB.Date = case when datepart(weekday, dbo.CutoffDate) IN (6,7)
then dateadd(d, -((datepart(weekday, dbo.CutoffDate) + 1 + @@DATEFIRST) % 7), dbo.CutoffDate)
else dbo.CutoffDate
end
Hope this helps.