how to make this query in sql server 2012

0

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:

and here I leave the der:

    
asked by Braian Wenger 30.06.2017 в 04:01
source

2 answers

-1

Hello, if I have already completed the previously prepared query, which would be: "Show the average of disapproved in each instance."

and the query is done this way:

could you help me see what is the error to get the average of disapproved

    
answered by 01.07.2017 в 16:14
-1

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.

    
answered by 06.07.2017 в 03:54