magic1
magic1

Reputation: 1

using "in" with a case statement

Is it possible to write something like

Case when a in (value1,value2) then b else a end

Upvotes: 0

Views: 91

Answers (1)

KM.
KM.

Reputation: 103589

YES.

try it out with a simple query:

SELECT CASE WHEN 2 in (1,2) then 'B' ELSE 'A' END 

OUTPUT:

----
B

(1 row(s) affected)

then:

SELECT CASE WHEN 3 in (1,2) then 'B' ELSE 'A' END 

OUTPUT:

----
A

(1 row(s) affected)

Upvotes: 9

Related Questions