RhythmAddict112
Programmer
Hey SQL Gurus,
Not sure if I'm just "not all there" today, or what...but here is the Q. I need to do a case statement in my where clause, this works:
But I need an additional OR clause in my else block, ex:
The above throws the following error:
Incorrect syntax near the keyword 'OR'. within the ELSE statement - not a surprise. I'm sure there is a workaround for this, but I just can't think of it right now. Any input would be great...thanks!
Not sure if I'm just "not all there" today, or what...but here is the Q. I need to do a case statement in my where clause, this works:
Code:
WHERE r.[SomeCol] = @SomeColVal
AND SomeOtherCol =
(
CASE WHEN (@Year = 0 AND @Period = 0) THEN
@SomeVal
CASE WHEN...
...
CASE ELSE
@SomeVal
END
But I need an additional OR clause in my else block, ex:
Code:
WHERE r.[SomeCol] = @SomeColVal
AND SomeOtherCol =
(
CASE WHEN (@Year = 0 AND @Period = 0) THEN
@SomeVal
CASE WHEN...
...
CASE ELSE
@SomeVal OR @SomeVal - 1
END
The above throws the following error:
Incorrect syntax near the keyword 'OR'. within the ELSE statement - not a surprise. I'm sure there is a workaround for this, but I just can't think of it right now. Any input would be great...thanks!