2
To get the desired result you can create a query
grouped by matricula_aluno
and use the function COUNT
together with a CASE
testing the spine acertou
:
SELECT r.matricula_aluno,
COUNT(CASE WHEN acertou THEN 1 END) AS acertos,
COUNT(CASE WHEN NOT acertou THEN 1 END) AS erros
FROM realizacao r
GROUP BY r.matricula_aluno
See working on SQL Fiddle.
Show! Vlw once again! :)
– Thiago Cunha