I have the following table:
Payments and the fields you have are idpagos
, codigo_empleado
, fecha_pago
, trimestre
, monto_pago
The payment quarter is because the employees are paid 15 and last of each month and I am identifying them as 1 for the first quarter and 2 for the second quarter.
What I want is to show me the entire list of the payments of each employee so that they do not repeat themselves and add the amounts paid from both quarters for each employee.
I tried this:
SELECT codigo_empleado, SUM(monto_pago)
FROM pagos WHERE MONTH(fecha_pago)=9 AND YEAR(fecha_pago)=2017
But it shows me only one employee_code and the sum of the total of all amounts paid from all employees in that month.