I have a scenario where I am trying to retrieve multiple values from a field/column based on a condition in a select statement. I was trying to use a Case Statement, but the problem is that the Case Statement does not support multiple values in a field/column. Is there any work around to this or any other way to achieve this?
SELECT col1, col2, col3, Period
FROM tblMonthlyCost
WHERE Period = CASE
WHEN Datepart(MONTH, Getdate()) = 8
AND Datediff(DAY, '07/31/2012', Getdate()) <= 3 THEN Period IN
('0112','0212','0312','0412','0512','0612')
WHEN Datepart(MONTH, Getdate()) = 8
AND Datediff(DAY, '07/31/2012', Getdate()) > 3 THEN Period IN
('0112','0212','0312','0412','0512','0612','0712')
END
Why not just do this?