Subject Re: deleting duplicate records
It's easy, firebird calculates the where clause for each row depending on CURRENT state of table, not depending on state BEFORE query.

So when You delete x - 1 rows with the same value, the very last row is not duplicate.

You have to create a procedure

begin

for select x from table_a group by x having count(*) > 1
into :id_x
do begin

delete from table_a where x = :id_x;

end

end

By, Tom