I have 2 data extensions, audience_1 and audience_2, which I would like to compare to see what contacts in audience_1 are unique, meaning they do not exist in both audiences. The only field that has matching values in both data extensions is Email_Address (aside from Email_Address, other columns that exist in both data extensions but have different values are Contact_Key, First_Name, and Last_Name. There is also the App_ID column which is unique to audience_1). After performing an INNER JOIN on Email_Address I get 1600 matching contacts out of 1900. My goal is to get the remaining 300 to see which contacts are unique. Any advice?
1 Answer
For this you would use a left or right join on email address (the common field) with the condition "IS NULL" on the related data extensions field you are matching with.
That gives you all subscribers that exist in one but not the other.
This is a simplified example query to get the records that only exist in audience 1:
Select a1.email
From audience1 a1
Left Join audience2 a2
On a1.email = a2.email
Where a2.email IS NULL