1
I’m suffering from duplicate data in the bank and I need to list them to verify and delete them. I consider as duplicated data when the value and date coincide, as in the example below, the values A and C are duplicated.
A: 2017-08-10 - 10.00
B: 2017-08-10 - 10.01
C: 2017-08-10 - 10.00
D: 2017-08-11 - 10.00
Through a precise query that only A and C appear.
A: 2017-08-10 - 10.00
C: 2017-08-10 - 10.00
I tried this way, but without success:
SELECT data, valor FROM tabela
WHERE data > '2017-04-17'
HAVING COUNT(valor) > 1
Unfortunately this way the data comes grouped. I tried to add GROUP BY primary_key
unsuccessful.
Note: Mysql 5.7
If you just want to list the duplicates you can do so:
SELECT data, valor, count(*) as quantidade FROM tabela WHERE data > '2017-04-17' GROUP BY data, valor HAVING COUNT(*) > 1
– Laércio Lopes
@Laérciolopes really is an alternative. It brings the right data, but it doesn’t bring the data back as needed. It’s still a good idea. Thank you.
– DNick