Skip to content

Instantly share code, notes, and snippets.

@pikonha
Created February 24, 2021 20:49
Show Gist options
  • Save pikonha/e063d1cad12d994acba496af934a1a3f to your computer and use it in GitHub Desktop.
Save pikonha/e063d1cad12d994acba496af934a1a3f to your computer and use it in GitHub Desktop.
[POSTGRES] Remove duplicates and left the first register
with uniq as (
select distinct on (table.a, table.b) *
from table
) delete from table table1 where table1.id not in (select id from uniq)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment