How to make a sum of the result of a query?

1

I hope you can support me, I need to make the sum of the result of the wages that I throw the previous query. The result I need would only be $ 17,500

    
asked by Arturo Ortiz Vázquez 29.11.2018 в 08:59
source

1 answer

0

Try this

SELECT SUM(tabla.Salario)
FROM (
    SELECT e.Nombre,e.Paterno,e.Materno,d.Nombre as Departamento, p.Descripcion as 
    Puesto,c.Salario
    FROM empleado e
    INNER JOIN
    (
      SELECT ID_emp,MAX(Fecha_Inicio),ID_depto,ID_puesto
      FROM labora
      GROUP BY ID_emp,ID_depto,ID_puesto
    ) as l
    ON e.ID_emp=l.ID_emp
    INNER JOIN departamento d ON l.ID_Depto=d.ID_Depto
    INNER JOIN puesto p ON l.ID_puesto=p.ID_puesto
    INNER JOIN contiene c ON l.ID_puesto=c.ID_puesto AND d.ID_depto=c.ID_depto
) AS tabla

The% co_of internal% that you have is wrong, because if you use an aggregate function and group them, you must group by columns, that is, by GROUP BY , ID_emp , ID_depto

    
answered by 29.11.2018 в 11:30