Received: from localhost.localdomain (postgresql.org [64.49.215.8]) by localhost (Postfix) with ESMTP id A1F8147593C for ; Sun, 19 May 2002 10:13:06 -0400 (EDT) Received: from rwcrmhc54.attbi.com (rwcrmhc54.attbi.com [216.148.227.87]) by postgresql.org (Postfix) with ESMTP id B114647593C for ; Sun, 19 May 2002 10:11:37 -0400 (EDT) Received: from prometheus ([24.147.26.177]) by rwcrmhc54.attbi.com (InterMail vM.4.01.03.27 201-229-121-127-20010626) with SMTP id <20020519141118.SEWU14522.rwcrmhc54.attbi.com@prometheus> for ; Sun, 19 May 2002 14:11:18 +0000 Message-ID: <001d01c1ff3f$d7d86470$b11a9318@prometheus> From: "Dan MacNeil" To: "pgsql-sql" References: Subject: count(boolean) Date: Sun, 19 May 2002 10:16:47 -0400 MIME-Version: 1.0 Content-Type: text/plain; charset="iso-8859-1" Content-Transfer-Encoding: 7bit X-Priority: 3 X-MSMail-Priority: Normal X-Mailer: Microsoft Outlook Express 5.50.4807.1700 X-MimeOLE: Produced By Microsoft MimeOLE V5.50.4807.1700 X-Archive-Number: 200205/194 X-Sequence-Number: 7829 I have a table answers_boolean: question_id | integer | not null evaluation_id | integer | not null value | 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