count(boolean) - Mailing list pgsql-sql

From Dan MacNeil
Subject count(boolean)
Date
Msg-id 001d01c1ff3f$d7d86470$b11a9318@prometheus
Whole thread Raw
In response to Re: Casting timestamp  ("Joel Burton" <joel@joelburton.com>)
Responses Re: count(boolean)  ("Joel Burton" <joel@joelburton.com>)
List pgsql-sql
I have a table answers_boolean:
question_id   | integer   | not nullevaluation_id | integer   | not nullvalue             | boolean |

I'd like output in the form:

question_id,  count_true, count_false

....where count_true is the number of questions answered "true"

SELECT    question_id AS id, value AS val , count(value) AS cnt
FROM    answers_boolean 
GROUP BY    question_id,value;

gives me:id | val | cnt
----+-----+----- 2 | f   |   3 2 | t   |   3 3 | f   |   2 3 | t   |   4

...which is sorta what I want.

I've looked through the docs & archive but haven't found the answer. 

TIA


pgsql-sql by date:

Previous
From: "Joel Burton"
Date:
Subject: Re: Casting timestamp
Next
From: "Joel Burton"
Date:
Subject: Re: count(boolean)