I have the following table:
I am trying to add ALL the 3141.39, 8328.43, etc to have a sum of how much they are, I am trying something like this:
SELECT DISTINCT(cod_parte), SUM(cantidad)
FROM dbo.Det_materiales
WHERE factura='1885'
GROUP BY cantidad, cod_parte
But my result is this:
Why doesn't it add the totality, if they are equal and how can I solve it?
It doesn't add because you're also grouping by the value
cantidad
. Also in your case, you don't need to useDISTINCT