Re: sum but not grouped by? - Mailing list pgsql-sql

From Luca Rasconi Master
Subject Re: sum but not grouped by?
Date
Msg-id 42F62031.9070700@students.cefriel.it
Whole thread Raw
In response to sum but not grouped by?  (Henry Ortega <juandelacruz@gmail.com>)
List pgsql-sql
let ff your table...<br /> try this:<br /><b>select </b><br />     a.id, <br />     a.date, <br />     a.hours, <br />
   (<b>select </b>sum(b.hours) <br />         <b>from </b>ff as b<br />         <b>where </b>a.id = b.id <br />        
<b>group</b>by b.id <br />     ) as a <br />     <b>from </b>ff as a;<br /><br /> bye,<br /> Luca<br /><br /> Henry
Ortegaha scritto:<br /><blockquote cite="mid2bffcc33050805092862a01b93@mail.gmail.com" type="cite"><pre wrap="">I have
theff 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?
              <a class="moz-txt-link-freetext"
href="http://www.postgresql.org/docs/faq">http://www.postgresql.org/docs/faq</a></pre></blockquote><br /> 

pgsql-sql by date:

Previous
From: Haris Saybasili
Date:
Subject: trigger between to different database
Next
From: Tom Lane
Date:
Subject: Re: insert into / select from / serial problem