Re: sum but not grouped by?
От | Mischa Sandberg |
---|---|
Тема | Re: sum but not grouped by? |
Дата | |
Msg-id | 1123260475.42f3983bafe6d@webmail.telus.net обсуждение исходный текст |
Ответ на | sum but not grouped by? (Henry Ortega <juandelacruz@gmail.com>) |
Ответы |
Re: sum but not grouped by?
|
Список | pgsql-sql |
Quoting Henry Ortega <juandelacruz@gmail.com>: > 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)
В списке pgsql-sql по дате отправления: