Hi, a query of mine slowed down significantly when this statement was
added into the where:
(DATEDIFF(day, Col_StartDate, GETDATE()) BETWEEN 1 AND
(SELECT CASE datepart(dw, getdate())
WHEN 1 THEN 2
WHEN 2 THEN 3
ELSE 1
END) )
What it is supposed to do is get Friday, Saturday and Sunday's data if
today is Monday -- in addition if the day is Sunday get Friday and
Saturdays data. Otherwise, just get yesterdays data. This works,
however it slowed down the query by 12X. I think it may be the use of
a "case" because if I hard code it there isn't a problem. Any
suggestions for alternatives?