Query to catch a student’s mistakes and successes

Asked

Viewed 30 times

2

I would like a query to catch mistakes and hits from a particular student of the following table below:

inserir a descrição da imagem aqui

1 answer

0


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.

  • 1

    Show! Vlw once again! :)

Browser other questions tagged

You are not signed in. Login or sign up in order to post.