I have a bank of products sold forming by id, name and value. I would like to do a procedure that would return total of each product that was sold. Algem knows how to do it?
That the result is
Mouse = 60
CPU = 1500
Keyboard = 100
You can use the SUM()
aggregation function to sum the values and group the results by the name of the products with the GROUP BY
clause.
SELECT
nome_produto [Nome do Produto],
SUM(valor_produto) [Valor Total]
FROM
produtos_vendidos
GROUP BY
nome_produto