不支持OR语句的WHEN子句中的CASE运算符。我怎样才能做到这一点?

CASE ebv.db_no
    WHEN 22978 OR 23218 OR 23219 THEN 'WECS 9500'
    ELSE 'WECS 9520'
END as wecs_system

最佳答案

该格式要求您使用以下任一种:

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

否则,请使用:
CASE
  WHEN ebv.db_no IN (22978, 23218, 23219) THEN 'WECS 9500'
  ELSE 'WECS 9520'
END as wecs_system

10-08 19:56