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 0BBA152A78 for ; Fri, 5 Aug 2005 14:53:29 -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 11268-05 for ; Fri, 5 Aug 2005 17:53:19 +0000 (GMT) Received: from wproxy.gmail.com (wproxy.gmail.com [64.233.184.200]) by svr1.postgresql.org (Postfix) with ESMTP id 31C7452A2D for ; Fri, 5 Aug 2005 14:53:15 -0300 (ADT) Received: by wproxy.gmail.com with SMTP id 69so97508wri for ; Fri, 05 Aug 2005 10:53:15 -0700 (PDT) DomainKey-Signature: a=rsa-sha1; q=dns; c=nofws; s=beta; d=gmail.com; h=received:message-id:date:from:reply-to:to:subject:in-reply-to:mime-version:content-type:content-transfer-encoding:content-disposition:references; b=uMqa6bjp/LTNZtY0wO7xiZadd3krbyEKZqHytsp+k5NTUeDVVysktRYrVJMYa8wM2Y8MtmV64aEXI7un9UgvwWJ5KQTIw9JCYVAy9Iyab8z2uwBNWHAo5Zh9C0/D0vWi8JA7AF+qaLYAiaq3H+7nSm2ANmzfB/ml88FZn780JzI= Received: by 10.54.53.62 with SMTP id b62mr2758343wra; Fri, 05 Aug 2005 10:53:15 -0700 (PDT) Received: by 10.54.124.17 with HTTP; Fri, 5 Aug 2005 10:53:14 -0700 (PDT) Message-ID: <2bffcc3305080510535e3c81ef@mail.gmail.com> Date: Fri, 5 Aug 2005 13:53:14 -0400 From: Henry Ortega Reply-To: Henry Ortega To: pgsql-sql@postgresql.org Subject: Re: sum but not grouped by? In-Reply-To: <1123260475.42f3983bafe6d@webmail.telus.net> Mime-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-1 Content-Transfer-Encoding: quoted-printable Content-Disposition: inline References: <2bffcc33050805092862a01b93@mail.gmail.com> <1123260475.42f3983bafe6d@webmail.telus.net> X-Virus-Scanned: by amavisd-new at hub.org X-Archive-Number: 200508/29 X-Sequence-Number: 22257 Is it possible at all to do this without any joins or subselect? On 8/5/05, Mischa Sandberg wrote: > Quoting Henry Ortega : >=20 > > 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. >=20 > You're really joining two sets: >=20 > 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) >=20 >=20 >=20 > ---------------------------(end of broadcast)--------------------------- > TIP 1: if posting/reading through Usenet, please send an appropriate > subscribe-nomail command to majordomo@postgresql.org so that your > message can get through to the mailing list cleanly >