0
How to select the total of requested amount to the sku_product?
I tried to use DISTINCT to group the sku_product, and failed to add the requested quantity_quantity.
SELECT DISTINCT
(P.url_img1) AS url_img,
(PPV.id_cliente) AS id_cliente,
(PPV.sku_produto) AS sku_produto,
(P.descricao_curta) AS descicao_produto,
(PPV.valor_unit) AS valor_unit,
(PPV.quantidade) AS quantidade_pedida,
(P.quantidade) AS quantidade_saldo
FROM pre_pedido PPV
JOIN produtos P ON PPV.sku_produto = P.sku
WHERE id_cliente = '1'
ORDER BY PPV.sku_produto
If you just think about the description, it would be basically
select sku_product, sum(quantidade_pedida) from pre_pedido group by sku_produto
, that is, sum the amount, group the sku. See if this already solves the problem– Ricardo Pontual
I followed your example simplifying the query and managed to get the desired result. I will post the answer with the correction in my code.
– Hugo Rutemberg