I have 3 tables: 1. contributions 2. contributions_volunteers 3. contributions_multas All these tables have an import field, and they are all related to the table: 4. associates What I want is to show the partner and the sum of their amounts in a single query (and that in a single line I show all the contributions for each associate) I enclose the query that I made, but that does not bounce me the correct results I throw out figures that do not correspond
SELECT A.id_asociados,
Concat(A.nombres, ' ', A.a_paterno, ' ', A.a_materno) AS socios,
Sum(B.importe) AS 'obligatorio',
Sum(C.importe) AS 'voluntario',
Sum(M.importe) AS 'multas'
FROM asociados A
INNER JOIN aportes B
ON A.id_asociados = B.id_asociados
INNER JOIN aportes_voluntarios C
ON A.id_asociados = C.id_asociados
INNER JOIN aportes_multas M
ON A.id_asociados = M.id_asociados
GROUP BY A.id_asociados