Received: from localhost (postgresql.org [64.49.215.8]) by postgresql.org (Postfix) with ESMTP id 76BEF476135 for ; Wed, 23 Oct 2002 16:20:24 -0400 (EDT) Received: from siddhasana.haddons.net (dsl-64-194-11-225.telocity.com [64.194.11.225]) by postgresql.org (Postfix) with ESMTP id B65E5476106 for ; Wed, 23 Oct 2002 16:20:23 -0400 (EDT) Received: from tomandshirl.com (localhost.localdomain [127.0.0.1]) by siddhasana.haddons.net (Postfix) with SMTP id 73E2C5B1CC for ; Wed, 23 Oct 2002 16:17:25 -0400 (EDT) Received: from 66.47.66.34 (SquirrelMail authenticated user tom) by tomandshirl.com with HTTP; Wed, 23 Oct 2002 13:17:25 -0700 (PDT) Message-ID: <31182.66.47.66.34.1035404245.squirrel@tomandshirl.com> Date: Wed, 23 Oct 2002 13:17:25 -0700 (PDT) Subject: Sum of Every Column From: "Tom Haddon" To: X-Priority: 3 Importance: Normal Reply-To: tom@haddons.net X-Mailer: SquirrelMail (version 1.2.8) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by AMaViS new-20020517 X-Archive-Number: 200210/313 X-Sequence-Number: 10030 Hi Folks, I'm hoping to put together a query that generates a report on a table with a large number of boolean fields. This report has to be able to adapt to the number of fields in the table. Essentially, I want it to provide the sum of TRUE values for each field for a given subset of the table. I've got the query that returns the subset of the table (this is based on a relationship with another table): SELECT breast_cancer_resources.* FROM breast_cancer_resources, agency_contact_info WHERE breast_cancer_resources.id=agency_contact_info.id AND agency_contact_info.guideregion=1 AND agency_contact_info.list_online=TRUE But I'm not sure how to generate the sum for each column. Should I be looking elsewhere than SQL to do this for me, such as php (this is for a web-based report)? Thanks, Tom