Intellipaat Back

Explore Courses Blog Tutorials Interview Questions
0 votes
2 views
in SQL by (20.3k points)

The OR in the WHEN clause of a CASE statement is not supported. How can I do this?

CASE ebv.db_no 

    WHEN 22978 OR 23218 OR 23219 THEN 'WECS 9500' 

    ELSE 'WECS 9520' 

END as wecs_system 

1 Answer

0 votes
by (40.7k points)

Use this code:

CASE ebv.db_no 

  WHEN 22978 THEN 'WECS 9500' 

  WHEN 23218 THEN 'WECS 9500'  

  WHEN 23219 THEN 'WECS 9500' 

  ELSE 'WECS 9520' 

END as wecs_system

Or 

CASE  

  WHEN ebv.db_no IN (22978, 23218, 23219) THEN 'WECS 9500' 

  ELSE 'WECS 9520' 

END as wecs_system

Related questions

31k questions

32.8k answers

501 comments

693 users

Browse Categories

...