Skip to content

Instantly share code, notes, and snippets.

@zuzannamj
Created November 20, 2020 09:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • 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