I have this Query SQL but when wanting to add a SUM
to the column CANT_DISPONIBLE
generates me an error, this is my Query
select EB.ARTICULO,EB.BODEGA,EB.CANT_DISPONIBLE,EB.CANT_RESERVADA
,EB.CANT_TRANSITO,EB.CANT_REMITIDA,SUM(EB.CANT_DISPONIBLE) X
from EXISTENCIA_BODEGA EB,ARTICULO CL
where
EB.ARTICULO=CL.ARTICULO AND
(EB.CANT_DISPONIBLE>0 or EB.CANT_REMITIDA>0 or
EB.CANT_TRANSITO>0 or EB.CANT_RESERVADA>0)
and (SUBSTRING(EB.BODEGA,1,1)='T'
OR SUBSTRING(EB.BODEGA,1,2)='VM'
OR SUBSTRING(EB.BODEGA,1,2)='CS')
and SUBSTRING(EB.BODEGA,1,2)<>'TA'
AND CL.CLASIFICACION_1 IN ('1010','1007')
order by EB.BODEGA
The error is because of:
Group By: Column 'EXISTENCIA_BODEGA.ARTICULO'
is invalid in the select list because it is not contained
in either an aggregate function or the GROUP BY clause.