From: Luca Rasconi Master <luca.rasconi@gmail.com>
To: Henry Ortega <juandelacruz@gmail.com>
Cc: pgsql-sql@postgresql.org
Subject: Re: sum but not grouped by?
Date: Sun, 07 Aug 2005 16:52:33 +0200
Message-ID: <42F62031.9070700@students.cefriel.it> (raw)
In-Reply-To: <2bffcc33050805092862a01b93@mail.gmail.com>
References: <2bffcc33050805092862a01b93@mail.gmail.com>
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
>
>
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: luca.rasconi@gmail.com, juandelacruz@gmail.com
Subject: Re: sum but not grouped by?
In-Reply-To: <42F62031.9070700@students.cefriel.it>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox