0

How to do if conditioning within SQL statements

SELECT su.emailAddress,
IF C.SubscriberKey IS alphanumeric THEN ''
ELSE C.SubscriberKey AS SUBSCRIBERKEY
FROM from [_CLICK] C
join [_SUBSCRIBERS] su
on su.SubscriberKey =C.SubscriberKey
0
3

You need to use CASE - WHEN - THEN - END constructs in Marketing Cloud, as Microsoft SQL is used in the background.

It somewhat looks like this:

CASE input_expression   
     WHEN when_expression THEN result_expression [ ...n ]   
     [ ELSE else_result_expression ]   
END   

I'm not sure if your is alphanumeric expression works, but if it doesn't you could also try using something like NOT LIKE '%[^0-9A-Za-z]%'. However, if it does, your query looks like this (I also removed the second from keyword):

SELECT
    su.emailAddress,
    CASE
        WHEN C.SubscriberKey IS alphanumeric THEN ''
        ELSE C.SubscriberKey
    END AS SUBSCRIBERKEY
FROM [_CLICK] C
JOIN [_SUBSCRIBERS] su
ON su.SubscriberKey = C.SubscriberKey

Further documentation:

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.