Between the table fields there is the field name, the field dt_add which is the date the record was inserted and dt_update which is the date of the last update of the record.
I would like to know how to return and delete repeated records, for example if there are 100 records with equal names, delete those with last update date less than 01/11/2017
Explaining better:
In a system was found a problem that resulted in insertions we say from more than 16 thousand repetitions to about 100 records with the same name and value in a given table.
It seems surreal but more than 16,000 duplicate records for each value and the error occurred with about 100 values. The error was noticed after analysis due to the high consumption of server resources, and it has been observed that the error has existed since 2014 due to the dates of insertions and updates of the records.
What will be done is to delete all those that are repeated with date less than 11/01/2017 in order to lessen the consumption of resources and the system will be corrected.
I do not know if I could be clear enough for the context.
In summary, I need a SQL select
to return all repeated records and a delete
in order to delete repeated records dated less than 01/11/2017.
About primary key
It has a primary key, but it is a table of configurations where there should be unique registers (if not this problem) and the system is based on the configuration name and value reference.
Example:
nome : habilitar-alertas
valor: true
nome : bloquear-clientes-pendentes
valor: false