I need to add the quantity of each product that was sold by grouping them by "product_id" and adding their quantities. That is, in the example below I have 4 requests that need to print on the screen + - as follows:
Total qtd coca cola : 6
Total qtd moda catupiry : 11
Total valor coca cola: 24,00
Total valor moda catupiry: 55,00
The data is saved in an json array in the SQL database.
[{"id_produto":"768","qtd":8,"valor_uni":"5.00","produto":"MODA COM CATUPIRY"}]
[{"id_produto":"750","qtd":2,"valor_uni":"4.00","produto":"COCA-COLA LATA"}]
[{"id_produto":"768","qtd":3,"valor_uni":"5.00","produto":"MODA COM CATUPIRY"}]
[{"id_produto":"750","qtd":4,"valor_uni":"4.00","produto":"COCA-COLA LATA"}]
I tried several ways a week ago and I could not. Could you help me?