Subject RE: [firebird-support] Need delete dupes SQL st8ment
Author Pete Bray
> Who knows how to delete duplicate values in a column via SQL. Some of the
> goofy data I ported over from an MS Access "database"

here's some tips from a doc I accumulated from this list a while back when i
had a similar problem. hopefully something in there will be applicable to
you.....

Pete
---------------

Deleting duplicates from a table with no primary key.

DELETE FROM
TableA t1
WHERE
NOT SINGULAR(SELECT * FROM TableA t2 WHERE t2.DUB_KEYS =
t1.DUB_KEYS)

more general solution that works using dB-key which is system unique key
for each row, credited to: Diane Brown

DELETE FROM XXX T1 WHERE EXISTS
(SELECT * FROM XXX T2 WHERE
(T2.column1 = T1.column1 or (T2.column1 is null and T2.column1 is
null)) AND
(T2.column2 = T1.column2 or (T2.column2 is null and T2.column2 is
null)) AND
(.......) AND
T2.RDB$DB_KEY > T1.RDB$DB_KEY))

Use '<' if you want to keep first row.

However, if there is another column which has unique values for each of the
duplicates then:

DELETE FROM T t1 WHERE EXISTS
(SELECT * FROM T t2 WHERE t1.Column1=t2.Column1 AND
t1.Column2>t2.Column2)