Delete duplicates with PostgreSQL using USING
Consise way to delete duplicates (depending on a condition, e.g. col1 and col2 being equal) while keeping the row with the highest id:
DELETE FROM
my_table delete
USING my_table check
WHERE
delete.id < check.id
AND delete.col1 = check.col1
AND delete.col2 = check.col2