Is there a way to make a CASE statement with an IN clause?
SELECT
CASE c.Number
IN (\'1121231\',\'31242323\') THEN 1
IN (\'234523\',\'2342423\') THEN 2
END A
The question is specific to SQL Server, but I would like to extend Martin Smith's answer.
SQL:2003 standard allows to define multiple values for simple case expression:
SELECT CASE c.Number
WHEN '1121231','31242323' THEN 1
WHEN '234523','2342423' THEN 2
END AS Test
FROM tblClient c;
It is optional feature: Comma-separated predicates in simple CASE expression“ (F263).
Syntax:
CASE
WHEN [, ...] THEN
[WHEN [, ...] THEN
...]
[ELSE ]
END
As for know I am not aware of any RDBMS that actually supports that syntax.