I have the following query:
SELECT
YEAR(NFDtEmis) AS 'Ano',
MONTH(NFDtEmis) AS 'Mes',
ItProduto AS 'Produto',
SUM(ItQtde) AS 'Quantidade total'
FROM NotasItens
INNER JOIN NotasFiscais
ON NFEmpresa = ItEmpresa
AND NFNumero = ItNfNumero
AND NFTIPO = ItTipo
INNER JOIN Tributos
ON TribEmpresa = ItEmpresa
AND TribCodigo = ItCFO
WHERE ItEmpresa = '03'
AND ItProduto = 'JKIT'
AND NFDtEmis >= '2016-04-01'
AND NFDtEmis <= '2017-07-31'
AND NFStatus = 'I'
AND NFTipo = 'S'
AND NFEmpresa = '03'
AND UPPER(RTRIM(LTRIM(TribTpCFOP))) = 'VENDA'
GROUP BY YEAR(NFDtEmis),
MONTH(NFDtEmis),
ItProduto,
ItQtde
ORDER BY YEAR(NFDtEmis), MONTH(NFDtEmis)
I wrote on the idea of bringing the total quantity sold of the product "JKit" for each month from April 2016, however I do not know why, it is repeating the month, rather than sum it all up.
I think it could be wrong with SUM()
Result: