i would like to build a CASE statement that incorporates the following logic, but the sql compiler does not like the 'OR' in my statement:
CASE expression
WHEN expression1 OR expression2
THEN <yadda yadda>
ELSE <yadda yadda>
END
more specific code below:
CASE @var1
WHEN '99' OR '22'
THEN
(CASE @var2
WHEN 'All' THEN col1
ELSE @var2
END)
END
DECLARE @Variable INT;
SET @Variable = 1;
SELECT
CASE
WHEN @Variable = 1 OR @Variable = 2 THEN 'It is 1 or 2'
WHEN @Variable = 3 THEN 'It is 3'
ELSE 'It is not 1, 2, or 3'
END AS [SomeField]
MSDN docs for CASE, OR, and Expressions.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With