0
I have the following query:
SELECT DISTINCT
CTRL_CARGA_PED_VENDA.CtrlCargaNum, ITEM_PED_VENDA.PedVendaNum,
PRODUTO.ProdCodEstr, PRODUTO.ProdNome, Sum(ITEM_PED_VENDA.ItPedVendaQtd) AS
QtdItem FROM ITEM_PED_VENDA, CTRL_CARGA_PED_VENDA, PRODUTO
WHERE CTRL_CARGA_PED_VENDA.PedVendaNum = ITEM_PED_VENDA.PedVendaNum
AND ITEM_PED_VENDA.EmpCod = CTRL_CARGA_PED_VENDA.EmpCod
AND ITEM_PED_VENDA.ProdCodEstr = PRODUTO.ProdCodEstr
AND CTRL_CARGA_PED_VENDA.EmpCod = '01'
AND CTRL_CARGA_PED_VENDA.CtrlCargaNum = '0000038'
GROUP BY
CTRL_CARGA_PED_VENDA.CtrlCargaNum,PRODUTO.ProdNome, ITEM_PED_VENDA.PedVendaNum, PRODUTO.ProdCodEstr, ITEM_PED_VENDA.ItPedVendaQtd
Works perfectly, as I do for him to add up the products that have equal values and leave only a single name?
It would not be the case to correct the name that is wrong?
– bfavaretto
I tried not to
– Felipe Michael da Fonseca
If you take the name it works but I need the name
– Felipe Michael da Fonseca
puts a MAX or MIN in the name, and takes it out of group by... rsrs also can not have "codprodest" right... and if they are different products, there is no reason to add...
– Rovann Linhalis
That’s exactly what I thought @Rovannlinhalis
– bfavaretto