If you want to delete the smallest amount:
DELETE p1
FROM produto p1
INNER JOIN produto p2 ON p1.produto = p2.produto
WHERE p1.quant < p2.quant;
If you want to delete the highest amount:
DELETE p1
FROM produto p1
INNER JOIN produto p2 ON p1.produto = p2.produto
WHERE p1.quant > p2.quant;
If you want to group the records would be as follows:
SELECT p.produto,
SUM(p.quant) AS quant
FROM produto p
GROUP BY p.produto;
If you want to group and then delete, do one solution after another:
SELECT p.produto,
SUM(p.quant) AS quant
FROM produto p
GROUP BY p.produto;
DELETE p1
FROM produto p1
INNER JOIN produto p2 ON p1.produto = p2.produto
WHERE p1.quant < p2.quant;
In the title you say delete, but in the body of the question you show the junction of the records. Got confused.
– Woss
It would be very interesting to have your query, but in this case you should use the group_by column
– Otto
believe it is duplicate too, the link that Sorack posted should solve your problem
– Rovann Linhalis
@Andersoncarloswoss was even explanation error. The idea is to delete the names of the repeated products, but keeping the sum value of all of them
– Italo Rodrigo