Skip to content

Instantly share code, notes, and snippets.

@dcs619
Last active August 11, 2016 16:10
Show Gist options
  • Select an option

  • Save dcs619/2763997 to your computer and use it in GitHub Desktop.

Select an option

Save dcs619/2763997 to your computer and use it in GitHub Desktop.
Remove Duplicates ex using CTE
WITH duplicates (name, address, city, state, id)
AS (
SELECT name, address, city, state, ROW_NUMBER() OVER (
PARTITION BY name, address, city, state
ORDER BY address desc
) AS id
FROM source
)
DELETE FROM duplicates
WHERE id > 1
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment