Note to self more than anything, this snippet was handy for to remove duplicate rows in SQL, that crept into a Postgres database as a result of a dodgy join.
There are probably more than a couple of ways of doing this but the best example I came up with after reading around is:
DELETE FROM table_nameWHERE ctid NOT IN ( SELECT min(ctid) FROM table_name GROUP BY field1, field2);
The reason this works revolves around the ctid field. This is a default field you don't have to specify Read more [...]