I have the following tables in a school attendance system:
INASISTENCIA(idinasistencia,fecha,idtipoinassitencia,idalumno);
TIPOINASISTENCIA(idtipoinasistencia,valor);
How can I count the total value of a student's absence within a quarter? In other words, from March to May, for example, when the notebook is put together, the total number of absences that you have is placed.
Try the following:
SELECT SUM(valor) as total
FROM tipoinasistencia
WHERE tipoinasistencia.idtipoinasistencia
IN ( SELECT idtipoinasistencia
FROM inasistencia
WHERE fecha BETWEEN '2016-08-08' AND '2016-09-17'
AND idalumno=3);
But it seems to be a one time account for each type of absence and not for each time an absence appears.
What can I do?