Skip to content

Instantly share code, notes, and snippets.

@zuzannamj
Created November 20, 2020 09:37
Show Gist options
  • Save zuzannamj/7521b300bd2cce8b067667b28e868ce9 to your computer and use it in GitHub Desktop.
Save zuzannamj/7521b300bd2cce8b067667b28e868ce9 to your computer and use it in GitHub Desktop.
SELECT contact.Email,
contact.Id
FROM ent.Contact_Salesforce contact
INNER JOIN (
SELECT Email,
MAX(Id) AS Id
FROM ent.Contact_Salesforce
GROUP BY Email
) aggr
ON aggr.Email = contact.Email AND aggr.Id = contact.Id
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment