Case statement with multiple conditions in SQL Server

Last Reply 10 months ago By chetan

Posted 10 months ago

Is it possible to combine this two into one?

 cmp.category=case when cmp.category='' OR cmp.category IS NULL OR cmp.category IS NOT NULL then dupl.category else cmp.category end,
 cmp.category=case when cmp.status!=1 and cmp.status!=2 then dupl.category else cmp.category end,


You are viewing reply posted by: pandeyism 10 months ago.
Posted 10 months ago

Hi chetan,

Refer below query according to query change your query.


SELECT CustomerId , CASE WHEN CustomerId = 1 OR CustomerId = 2 AND CustomerId = 3  THEN  'True'
WHEN CustomerId = 4 THEN 'False'
ELSE 'Nothing' 
END Result
FROM Customers