I have a query that returns the data I want, but to avoid using so many cycles in the programming part to present the information the way I want, I would like to know if there is any way to accommodate the next result of an sql query:
as follows:
query that I use:
SELECT A.Apellidos, M.Materia, FORMAT(SUM(FORMAT((N.Nota_Obtenida * (T.Ponderacion / 100)), 2)), 2) AS promedio, ME.Mes
FROM materia_grado MG
INNER JOIN grado G ON MG.Id_Grado = G.Id_Grado
INNER JOIN materia M ON MG.Id_Materia = M.Id_Materia
INNER JOIN tarea T ON T.Id_Materia_Grado = MG.Id_Materia_Grado
INNER JOIN nota N ON T.Id_Tarea = N.Id_Tarea
INNER JOIN grado_seccion GS ON G.Id_Grado = GS.Id_Grado
INNER JOIN seccion S ON S.Id_Seccion = GS.Id_Seccion
INNER JOIN especialidad E ON E.Id_Especialidad = GS.Id_Especialidad
INNER JOIN tipo_especialidad TE ON TE.Id_Tipo_Especialidad = E.Id_Tipo_Especialidad
INNER JOIN alumno_grado_seccion AGS ON AGS.Id_Grado_Seccion = GS.Id_Grado_Seccion
INNER JOIN alumno A ON A.Id_Alumno = AGS.Id_Alumno AND A.Id_Alumno = N.Id_Alumno
INNER JOIN mes ME ON ME.Id_Mes = T.Id_Mes
INNER JOIN periodo PE ON PE.Id_Periodo = ME.Id_Periodo
AND N.Id_Alumno = ?
AND YEAR(T.Fecha_Entrega) = YEAR(NOW())
AND ME.Status = 1
GROUP BY N.Id_Alumno, ME.Id_Mes, MG.Id_Materia_Grado
ORDER BY A.Apellidos