0
In my bank I have a table that has a list of (carrier and waste specifications) where the carriers can have several waste, I checked that the data are duplicated and are represented in this way:
code_specification | carrier code | specifications
1 | 2 | 1
2 | 2 | 5
3 | 5 | 2
4 | 5 | 5
5 | 5 | 2
6 | 8 | 1
7 | 9 | 5
8 | 9 | 5
9 | 10 | 1
10 | 10 | 3
11 | 10 | 1
12 | 10 | 1
13 | 10 | 5
I made a query to tell me the duplicate line quantity and it worked but with doubts to remove these duplicate data from the bank.
SELECT codigotransportadora,especificacoesresi, count(*) FROM transportadorasespecificacoesresiduos
WHERE
codigotransportadora <> 0
AND especificacoesresi<> 0
GROUP BY codigotransportadora,especificacoesresi
HAVING COUNT(*) > 1
ORDER BY codigotransportadora)
Outcome of the consultation :
carrier code | specifications resi| Count
5 | 2 | 2
9 | 5 | 2
10 | 1 | 3
I’m racking my brain trying to create a script to delete these duplicates...
put in http://sqlfiddle.com/ if possible, and what is the condition to delete ?
5|2
has thecodigotrans_especificacoes_residuos
like 3 and 5, which one erases ?– Rovann Linhalis
in the result of the query shows the amount of duplicated, so looking for a way to delete and leave only one record.
– Mailson Anselmo
I know, but the column
codigotrans_especificacoes_residuos
is not duplicated, which one will be deleted ?– Rovann Linhalis
whatever makes will not impact on my application, however only need to have a record.
– Mailson Anselmo