Case When to replace nested IIF statement

10-15-2004, 03:42 AM
I have a nested IIF statement such as:

IIf(blnWarning, IIf(strStage = 'Predicted' Or strStage = 'Requested', "State A", "State B"), "State C")

how can I convert that to a Case When statement inside a SQL statement?

I've tried

Case When blnWarning AND (strStage = 'Predicted' Or strStage = 'Requested') Then "State A"
Case When blnWarning AND NOT (strStage = 'Predicted' Or strStage = 'Requested') Then "State B"
Case When Not blnWarning Then "State C" End As myField

but I get an error message stating:

Incorrect syntax near the keyword 'And'.

10-15-2004, 06:02 PM
Something like:

SELECT myField =
CASE type
WHEN 'this_value' THEN 'MKoslof'
WHEN 'second_value' THEN 'Hello'
WHEN 'business' THEN 'Business'
ELSE 'Undetermined value'
END, <continue statement>

EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum