I have a problem in a query, in this query I have the students enrolled in a section of a specific year and their averages. My goal is how I can get the number of students who pulled at least one course in that year.
select N.Descripcion as Nivel,G.Grado, S.Nombre as Seccion,A.Nombre,
M.MatriculaID
,AA.Denominacion as Periodo , Promedio=AVG(E.Nota), c.Nombre as Curso
from alumno A
inner join Matricula M
ON A.AlumnoID=M.FK_AlumnoID
inner join AÑO_ACADEMICO aa
ON aa.AñoID=M.FK_AñoID
inner join SECCION S
ON S.SeccionID=M.FK_SeccionID
inner join Nivel N
ON N.NivelID=S.FK_NivelID
inner join Grado g
ON G.GradoID=S.FK_GradoID
inner join Evaluacion E
ON M.MatriculaID= E.FK_MatriculaID
inner join Bimestre B
ON B.BimestreID=E.FK_BimestreID AND B.FK_AñoID=AA.AñoID
inner join detalle_curso DC
ON DC.DetalleCursoID=E.FK_DetalleCursoID
inner join curso c
ON C.CursoID=DC.FK_CursoID
Group by N.Descripcion,G.Grado,S.Nombre,A.Nombre,M.MatriculaID,AA.Denominacion ,C.Nombre
having AVG(E.Nota)<10.5
order by AA.Denominacion,N.Descripcion,G.Grado,S.Nombre,A.Nombre asc
Another problem is that if the student pulled two courses in a year, I want to count it as one.
Currently the result of my query is this.