I have a simple case statement I am looking for a little assistance with if possible?
I need to make the WHERE clause of my statement dynamic in so much as, dependant upon the value of a column, another column is evaulated differently.
so if I was writing this as an if..then it would go
if col1 = 'Weekly' then
Statement = ""
else
Statement = ""
end if
Here's the statement
SELECT TradeCustomerID, BusinessName FROM Customers_Trade WHERE AutoStatement = 'Manual' AND (CASE AutoStatementFrequency WHEN 'Weekly' THEN (DateDiff(d,AutoStatementLastDate, getdate()) > 7) ELSE ((DateDiff(m,AutoStatementLastDate, getdate()) > 0 AND Day(getdate()) > Day(AutoStatementLastDate)) END)
Anyone help me get to the bottom of this please?