Deleting duplicates in a form

Deleting duplicates in a form

I am trying to find an algorithm where I can find all duplicates in a form according to a key field or composite key field, and in each group of duplicates I only keep the oldest record per Add date. 

How can this be achieved with Deluge? Thanks