2

Good morning,

I was wondering if one of you could help me - should be fairly quick I'd imagine; I'm a newbie so prone to missing obvious things.

I have the below statement which is returning the aforementioned 905 error...any ideas?

Thanks in advance.

(CASE CONTACTS.TELEPHONE_NO_DAY
    WHEN CONTACTS.TELEPHONE_NO_DAY LIKE '07%'
    THEN CONTACTS.TELEPHONE_NO_DAY
    ELSE NULL
    END) TEL_DAY,
   (CASE CONTACTS.TELEPHONE_NO_EVE
    WHEN CONTACTS.TELEPHONE_NO_EVE LIKE '07%'
    THEN CONTACTS.TELEPHONE_NO_EVE
    ELSE NULL
    END) TEL_EVE
4

1 回答 1

11

您正在混淆两种处理案例的方式。您要么需要:

CASE <expression>
WHEN <comparison expression> THEN <return expression>
...

或者

CASE
WHEN <condition> THEN <return expression>
...

这些是docs中的“简单”和“搜索”变体。

但是因为你不能like在第一个版本中使用,你需要第二个:

CASE
WHEN CONTACTS.TELEPHONE_NO_DAY LIKE '07%'
THEN CONTACTS.TELEPHONE_NO_DAY
ELSE NULL
END

您也不需要两个case语句周围的括号。

于 2012-09-25T09:40:15.240 回答