Re: sum but not grouped by?

From: Luca Rasconi Master <luca(dot)rasconi(at)gmail(dot)com>
To: Henry Ortega <juandelacruz(at)gmail(dot)com>
Cc: pgsql-sql(at)postgresql(dot)org
Subject: Re: sum but not grouped by?
Date: 2005-08-07 14:52:33
Message-ID: 42F62031.9070700@students.cefriel.it
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

let ff your table...
try this:
*select *
a.id,
a.date,
a.hours,
(*select *sum(b.hours)
*from *ff as b
*where *a.id = b.id
*group *by b.id
) as a
*from *ff as a;

bye,
Luca

Henry Ortega ha scritto:

>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.
>
>---------------------------(end of broadcast)---------------------------
>TIP 3: Have you checked our extensive FAQ?
>
> http://www.postgresql.org/docs/faq
>
>

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Haris Saybasili 2005-08-08 18:41:22 trigger between to different database
Previous Message Mischa Sandberg 2005-08-07 06:55:41 Re: sum but not grouped by?