Hi, I need to do this query in sql but I do not know how to do it. I wanted to know if you could help me. the query would be "Show the average of disapproved in each instance." which instance in my case would be the type table:
You have to look for the query to return something similar to this table:
The fourth column of this table is calculated based on the values of the other 2 previous ones.
But EYE : because in your query you would be calculating all the evaluations of all the subjects of the University and of all the Courses and of all the races. So you should also filter that data.
For that the table that stores the evaluations is the most important. Not the students.
SELECT tipo.nombre ,
COUNT (CASE WHEN evaluaciones.nota < 4 THEN 1 ELSE 0 END) AS TD ,
COUNT (CASE WHEN evaluaciones.nota >=0 THEN 1 ELSE 0 END) AS TG ,
(TD/TG)*100 AS PED
FROM Evaluacion INNER JOIN tipo ON Evaluacion.idTipo = tipo.idTipo
GROUP BY tipo.nombre
In principle, what you asked for should be something like this above.
But to make sense, you should also include the JOIN
with the table FORMAT and thus be able to filter by idMateria
and idCurso
.
HAVING planilla.idMateria=Valor1 AND planilla.idCurso=Valor2
I hope it works for you.