I have a teacher evaluation table and another one with student assessments:
tbl_professor
id | nome
----------------------------
1 | José
2 | Maria
3 | Paulo
tbl_avaliacao
id | idprofessor | avaliacao | data
-------------------------------------
1 | 3 | R | 2015-01-01
2 | 2 | B | 2015-01-01
3 | 3 | B | 2015-01-01
Student evaluation can be R-Bad, B-Good, but how could you create a listing like below using OVER because it does not allow you to put a WHERE for this type of filtering?
avaliacoes_ruins | avaliacoes_boas
----------------------------------
1 | 2
Or
professor |avaliacoes_ruins |avaliacoes_boas
---------------------------------------------
José |0 |0
Maria |0 |1
Paulo |1 |1
I know the last case would be possible to do SQL
SELECT
nome,
(SELECT (COUNT) FROM tbl_avaliacao WHERE idprofessor = tbl_professor.id AND avaliacao = 'R') AS avaliacoes_ruins,
(SELECT (COUNT) FROM tbl_avaliacao WHERE idprofessor = tbl_professor.id AND avaliacao = 'B') AS avaliacoes_boas
FROM
tbl_professor
But in the above case the cost of SQL will be high.