mostrar - sql eliminar registros repetidos dejando solo 1
PostgresSQL cómo eliminar valores duplicados (3)
Creo que estás pidiendo esto:
DELETE FROM tablename WHERE id IN (SELECT id FROM (SELECT id, ROW_NUMBER() OVER (partition BY column1, column2, column3 ORDER BY id) AS rnum FROM tablename) t WHERE t.rnum > 1);
Parece que solo desea eliminar los registros duplicados con respecto a la columna de translationset_id
. En este caso, podemos usar la funcionalidad de número de fila de Postgres para discernir entre filas duplicadas, y luego eliminar esos duplicados.
WITH cte AS
(
SELECT t.*, ROW_NUMBER() OVER (PARTITION BY translationset_id, key) AS rnum
FROM yourTable t
)
DELETE FROM yourTable
WHERE translationset_id IN (SELECT translationset_id FROM cte WHERE rnum > 1)
delete from mytable
where exists (select 1
from mytable t2
where t2.name = mytable.name and
t2.address = mytable.address and
t2.zip = mytable.zip and
t2.ctid > mytable.ctid
);