I have a table with the following structure:
Id Email Unsubscribed 1 email_1 0 2 email_2 0 3 email_3 1 4 email_1 1 5 email_4 1 6 email_3 0 7 email_1 0 8 email_4 1
I am trying to query for all duplicate emails that have different values in the Unsubscribed column. I want to return something like this based on the above example:
Email email_1 email_3
Advertisement
Answer
It think you just want this:
SELECT Email FROM yourTable GROUP BY Email HAVING MIN(Unsubscribed) <> MAX(Unsubscribed);
The HAVING
clause would only assert to true if a given email appeared with more than one value for unsubscribed.