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 433F852965 for ; Fri, 5 Aug 2005 13:48:05 -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 72275-06 for ; Fri, 5 Aug 2005 16:47:58 +0000 (GMT) Received: from priv-edmwes25.telusplanet.net (defout.telus.net [204.209.205.55]) by svr1.postgresql.org (Postfix) with ESMTP id A5DE652922 for ; Fri, 5 Aug 2005 13:47:56 -0300 (ADT) Received: from localhost ([204.209.205.55]) by priv-edmwes25.telusplanet.net (InterMail vM.6.01.04.04 201-2131-118-104-20050224) with ESMTP id <20050805164755.HLVR796.priv-edmwes25.telusplanet.net@localhost> for ; Fri, 5 Aug 2005 10:47:55 -0600 Received: from 209.17.183.249 ( [209.17.183.249]) as user a3a18850@204.209.205.53 by webmail.telus.net with HTTP; Fri, 5 Aug 2005 09:47:55 -0700 Message-ID: <1123260475.42f3983bafe6d@webmail.telus.net> Date: Fri, 5 Aug 2005 09:47:55 -0700 From: Mischa Sandberg To: pgsql-sql@postgresql.org Subject: Re: sum but not grouped by? References: <2bffcc33050805092862a01b93@mail.gmail.com> In-Reply-To: <2bffcc33050805092862a01b93@mail.gmail.com> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: 8bit User-Agent: Internet Messaging Program (IMP) 3.1-cvs X-Originating-IP: 209.17.183.249 X-Virus-Scanned: by amavisd-new at hub.org X-Spam-Status: No, hits=1.053 tagged_above=0 required=5 tests=AWL, DNS_FROM_RFC_POST, FORGED_RCVD_HELO X-Spam-Level: * X-Archive-Number: 200508/28 X-Sequence-Number: 22256 Quoting Henry Ortega : > I have the ff data: > > id | date | hours > AAA 07-01-2005 3 > AAA 07-02-2005 4 > BBB 07-01-2005 6 > BBB 07-02-2005 2 > BBB 07-03-2005 7 > > Would it be possible to get the ff: > > id | date | hours | id_total > AAA 07-01-2005 3 7 > AAA 07-02-2005 4 7 > BBB 07-01-2005 6 15 > BBB 07-02-2005 2 15 > BBB 07-03-2005 7 15 > > So it's like SUM OF, but not Grouped By? Is this possible at all? > Thank you for any help. You're really joining two sets: select FFDATA.id, FFDATA.date, FFDATA.hours, FFSUM.id_total from FFDATA join (select id, sum(hours) as id_total from FFDATA group by id ) as FFSUM using(id)