PostgreSQL: Catching bugs and hits

0

I need a query to get the number of errors and hits from this table.

    
asked by anonymous 15.05.2018 / 21:41

1 answer

3

Something like that:

SELECT t.acertou,
       COUNT(1)
  FROM tabela t
 GROUP BY t.acertou

If you wanted to show as just a record, you can use subquery :

SELECT (SELECT COUNT(1)
          FROM tabela t
         WHERE t.acertou) AS acertos,
       (SELECT COUNT(1)
          FROM tabela t
         WHERE NOT t.acertou) AS erros
    
15.05.2018 / 21:47