Query to get errors and hits from a student

2

I would like a query to get errors and hits from a particular student from the following table below:

    
asked by anonymous 15.05.2018 / 22:15

1 answer

0

To get to the desired result you can create a query grouped by matricula_aluno and use the COUNT function together with a CASE by testing the acertou column:

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 in SQL Fiddle.

    
15.05.2018 / 22:26