Syntax for CASE WHEN with multiple criteria

UPDATE #tmp
SET   Product_Type = CASE plcy.PTYP_ID WHEN 4 OR 8 OR 11 OR 15 OR 16 OR 17) then 'B' else 'A' END

What's the correct syntax for CASE WHEN {multiple values} THEN {something} END?

TIA
-Jim
LVL 66
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAsked:
Who is Participating?
 
morisceConnect With a Mentor Commented:
UPDATE #tmp
SET  Product_Type = CASE when plcy.PTYP_ID in ( 4,  8, 11,15, 16,17) then 'B' else 'A' END
0
 
flavoConnect With a Mentor Commented:
CASE WHEN plcy.PTYP_ID  = 4 OR plcy.PTYP_ID  = 8 OR plcy.PTYP_ID  =  11 OR plcy.PTYP_ID  = 15 OR plcy.PTYP_ID  = 16 OR plcy.PTYP_ID  = 17)
0
 
Jim P.Connect With a Mentor Commented:
Have you tried:
----------------------------------------
UPDATE #tmp
SET   Product_Type = CASE plcy.PTYP_ID WHEN 4, 8, 11,  15, 16, 17 then 'B' else 'A' END
0
Cloud Class® Course: Amazon Web Services - Basic

Are you thinking about creating an Amazon Web Services account for your business? Not sure where to start? In this course you’ll get an overview of the history of AWS and take a tour of their user interface.

 
Jim HornMicrosoft SQL Server Developer, Architect, and AuthorAuthor Commented:
Thanks guys.  I was using the IN, but for some reason not able to get it to work.
0
 
Jim P.Commented:
>>  16 OR 17) then 'B' els

You had an unclosed paren in the original.
0
 
Jim P.Commented:
Glad to be of assistance. May all your days get brighter and brighter.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.