Created
October 25, 2021 20:08
-
-
Save zuzannamj/702529eda6d46586549f41483c13afad to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
SELECT | |
contact.Id as SubscriberKey, | |
contact.Email as EmailAddress, | |
CASE | |
WHEN allsub.Status = 'held' THEN 'active' | |
WHEN allsub.Status = 'bounced' THEN 'active' | |
ELSE allsub.Status | |
END as Status | |
FROM | |
Contact_Salesforce as contact | |
RIGHT JOIN | |
_subscribers as allsub | |
ON contact.Id = allsub.SubscriberKey | |
WHERE contact.Email != allsub.EmailAddress | |
UNION | |
SELECT | |
lead.Id as SubscriberKey, | |
lead.Email as EmailAddress, | |
CASE | |
WHEN allsub.Status = 'held' THEN 'active' | |
WHEN allsub.Status = 'bounced' THEN 'active' | |
ELSE allsub.Status | |
END as Status | |
FROM | |
Lead_Salesforce as lead | |
RIGHT JOIN | |
_subscribers as allsub | |
ON lead.Id = allsub.SubscriberKey | |
WHERE lead.Email != allsub.EmailAddress |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment