este select da la lista de TODOS los movimientos de compras de productos, pero necesito ADEMAS tener el TOTAL del stock de cada producto,
y no logro hacerlo, intente con SUM(...) pero no me lo hace.
Select
a.id AS c1,
a.idprod AS c2,
a.fecha AS c3,
a.importe AS c4,
a.stock AS c5,
a.stockminimo AS c6,
a.ganancia AS c7,
c.nombre AS c8,
d.id AS c9,
d.nombre AS c10,
e.id AS c11,
e.nombre AS c12,
f.stockcongelado AS c13,
f.punitario AS c14
FROM tbprecio a
LEFT JOIN tbprod AS b ON b.id = a.idprod
LEFT JOIN tbprodnom AS c ON b.idnombre = c.id
LEFT JOIN tbsucursal AS d ON b.idsucursal = d.id
LEFT JOIN tbdistribuidores AS e ON b.iddistribuidor = e.id
LEFT JOIN tbstockres AS f ON f.idprod = a.idprod
ORDER BY a.idprod, b.idsucursal, a.fecha
el campo a sumar es "C5"
gracias