X-Original-To: pgsql-sql-postgresql.org@localhost.postgresql.org Received: from localhost (unknown [200.46.204.144]) by svr1.postgresql.org (Postfix) with ESMTP id 4939C53AF1 for ; Fri, 15 Apr 2005 09:53:37 -0300 (ADT) Received: from svr1.postgresql.org ([200.46.204.71]) by localhost (av.hub.org [200.46.204.144]) (amavisd-new, port 10024) with ESMTP id 95458-06 for ; Fri, 15 Apr 2005 12:53:32 +0000 (GMT) Received: from fed1rmmtao03.cox.net (fed1rmmtao03.cox.net [68.230.241.36]) by svr1.postgresql.org (Postfix) with ESMTP id 861D053ADA for ; Fri, 15 Apr 2005 09:53:30 -0300 (ADT) Received: from newton.gnova.com ([68.111.226.8]) by fed1rmmtao03.cox.net (InterMail vM.6.01.04.00 201-2131-118-20041027) with ESMTP id <20050415125334.VFGV1282.fed1rmmtao03.cox.net@newton.gnova.com>; Fri, 15 Apr 2005 08:53:34 -0400 Received: from newton.gnova.com (newton.gnova.com [127.0.0.1]) by newton.gnova.com (8.12.8/8.12.8) with ESMTP id j3FCrGfr021870; Fri, 15 Apr 2005 05:53:16 -0700 Received: (from apache@localhost) by newton.gnova.com (8.12.8/8.12.5/Submit) id j3FCqqeA021866; Fri, 15 Apr 2005 05:52:52 -0700 X-Authentication-Warning: newton.gnova.com: apache set sender to tjo@acm.org using -f Received: from 12.10.164.2 (SquirrelMail authenticated user tjo) by gnova.com with HTTP; Fri, 15 Apr 2005 05:52:52 -0700 (PDT) Message-ID: <1168.12.10.164.2.1113569572.squirrel@gnova.com> Date: Fri, 15 Apr 2005 05:52:52 -0700 (PDT) Subject: From: "TJ O'Donnell" To: X-Priority: 3 Importance: Normal Cc: Reply-To: tjo@acm.org X-Mailer: SquirrelMail (version 1.2.11) MIME-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Transfer-Encoding: 8bit X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=0.812 tagged_above=0 required=5 tests=AWL, FORGED_RCVD_HELO, MISSING_SUBJECT X-Spam-Level: X-Archive-Number: 200504/224 X-Sequence-Number: 21117 There some documentation about aggregate functions in the manual, for example: http://www.postgresql.org/docs/7.4/static/sql-createaggregate.html Here's a simple agg function that should work for you, assuming your col types are int4. CREATE AGGREGATE andsum ( sfunc = int4and, basetype = int4, stype = int4 ); TJ