Skip to main content

@Mateusz Dąbrowski thank you for your amazing guide at: https://mateuszdabrowski.pl/docs/sql/sfmc-sql-case/ just want to confirm because it's looking right that the following makes sense from a coding standpoint...use case is feeding the DE for an AllSub ETL update.  We are updating SFMC subscriber status to Unsubscribed to align with unsub fields in CRM.  The reason why we need CASE is that we want to use the CRM email address when provided not AllSubs, and only use AllSub when the CRM email address is null.  Does this make sense?  Don't want Allsub email address to overwrite CRM email address for others except when CRM is null.  Data looks right when running the DE (testing/viewing the data before the ETL process).

Use case for CASE pulling the right email address 

2 respuestas
  1. Mateusz Dąbrowski (mateuszdabrowski.pl) Forum Ambassador
    12 ago 2022, 13:13

    Perfectly fine CASE Tim, however, the Status should be written the other way round. 

    Also, while the CASE is correctly written and will work as you want, you can optimise it in terms of readability with NULL Functions:

    SELECT

    sfdc.Id AS SubscriberKey

    , COALESCE(sfdc.Email, allsub.EmailAddress) AS EmailAddress

    , 'unsubscribed' AS Status

0/9000