I have a data extension A with a field "Exist_in_SF". I already have records residing in DE A, and I want to update the records in the same data extension with "TRUE" value in "Exist_in_SF" field if DE A's email address data exists in Lead/Contact objects, and otherwise "FALSE". However, the SQL that I wrote is not updating the "Exist_in_SF" field properly, and I am quite stuck. What should be the modification I should take in my SQL?
Below is my current SQL codes:
SELECT A.[EmailAddress],
CASE WHEN
(A.[EmailAddress] = SF.[Email]) THEN 'True'
ELSE 'False'
END as [Exists_in_SF]
from [Data Extension A] A
INNER JOIN (SELECT l.[email]
FROM ent.[lead_salesforce] l
GROUP BY l.[email]
UNION
SELECT c.[email]
FROM ent.[contact_salesforce] c
GROUP BY c.[email]) SF
ON A.[EmailAddress] = SF.[email]
Thanks in advance!