I need to add the salaries of the next query I have and sort them by description.
select distinct
cp.descripcion,
cp.idSysCPPuestos,
em.sueldoDiario,
em.sueldoIntegrado,
em.idSysCPCentroCosto
--,sum(CAST(em.sueldoDiario AS DECIMAL(18, 4)))+sum(CAST(em.sueldoIntegrado AS DECIMAL(18, 4)))
from
sysCPEmpleados ce
inner join sysCPCentroCosto cc on
ce.idSysCPCentroCosto = cc.idSysCPCentroCosto and
ce.idSysCPEmpresas = cc.idSysCPEmpresas
inner join sysCPEmpleados em on
em.idSysCPEmpresas = cc.idSysCPEmpresas
inner join sysCPPuestos cp on
em.idSysCPPuestos = cp.idSysCPPuestos
where cc.idSysCPCentroCosto = 'y'
and em.idSysCPEmpresas = 'x'
this is what I have and what gives me back
up here all right,
but if I try to make the commented sum, it returns me the following
Column 'sysCPPuestos.descripcion' is invalid in the select list because it is not contained in either aggregate function or the GROUP BY clause.
Someone could instruct me how to do this operation correctly, what I need is to add the amounts where the description of cc.description is the same. A thousand thanks.