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 C8F0652932 for ; Tue, 31 May 2005 17:22:07 -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 73846-08 for ; Tue, 31 May 2005 20:21:52 +0000 (GMT) Received: from mr1.surnet.cl (smtp1.surnet.cl [216.155.73.162]) by svr1.postgresql.org (Postfix) with ESMTP id 3995952A96 for ; Tue, 31 May 2005 17:17:04 -0300 (ADT) Received: from smtp1.surnet.cl (216.155.73.168) by mr1.surnet.cl (7.0.031.3) id 42587EDE00AE706D; Tue, 31 May 2005 16:16:35 -0400 Received: from smtp2.surnet.cl (smtp2.surnet.cl []) by mr1.surnet.cl ([216.155.73.168]); Tue, 31 May 2005 20:16:35 +0000 Received: from cluster.surnet.cl (216.155.73.164) by smtp2.surnet.cl (7.0.031.3) id 4259ADE3006A7C68; Tue, 31 May 2005 16:17:26 -0400 Received: from localhost (216.155.79.202) by cluster.surnet.cl (7.0.024) id 4276578F003FDA04; Tue, 31 May 2005 16:17:05 -0400 Received: by localhost (Postfix, from userid 1000) id E017DD09034; Tue, 31 May 2005 16:17:11 -0400 (CLT) Date: Tue, 31 May 2005 16:17:11 -0400 From: Alvaro Herrera To: lucas@presserv.org Cc: pgsql-sql@postgresql.org Subject: Re: Sum() rows Message-ID: <20050531201711.GH9257@surnet.cl> References: <20050531133648.cypdc5lnjtc0wsws@www.presserv.org> Mime-Version: 1.0 Content-Type: text/plain; charset=iso-8859-1 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20050531133648.cypdc5lnjtc0wsws@www.presserv.org> User-Agent: Mutt/1.5.9i X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.616 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_ABUSE, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200505/284 X-Sequence-Number: 21597 On Tue, May 31, 2005 at 01:36:48PM -0300, lucas@presserv.org wrote: > Hi. > How can I sum a row and show the sum for each row??? > For example, in a finances table that have the total movimentation(debit/credit) > in the bank. I think you can write an aggregate in, say PL/Python to do this. IIRC there was an article on General Bits about this. Search for "running aggregates". I think there is something in issue #23. See #29 as well. -- Alvaro Herrera () "Las cosas son buenas o malas segun las hace nuestra opinión" (Lisias)