Re: FIRST_VALUE: need to group by argument?

Поиск
Список
Период
Сортировка
Искать
От
Manuel Gómez
Тема
Re: FIRST_VALUE: need to group by argument?
Дата
в 16:13:44
Msg-id
CAJWnFaO6GcbhoJS8Rjo1Jf8brCPDOPPufkt-aBC2iK+oU1LuTA@mail.gmail.com
Ответ на
Список
Дерево обсуждения
FIRST_VALUE: need to group by argument? Guyren Howe <guyren@gmail.com>
Re: FIRST_VALUE: need to group by argument? "David G. Johnston" <david.g.johnston@gmail.com>
Re: FIRST_VALUE: need to group by argument? Manuel Gómez <targen@gmail.com>
Re: FIRST_VALUE: need to group by argument? "David G. Johnston" <david.g.johnston@gmail.com>
On Tue, May 24, 2016 at 8:50 AM, David G. Johnston
 wrote:
> SELECT x, sum(i), sum(sum(i)) OVER (PARTITION BY x) FROM ( VALUES (a,1),
> (a,2), (b,3) ) val (x,i) GROUP BY x
> yields
> a, 3, 6
> b, 3, 6

Thank you for this enlightening explanation!  I was, however, very
confused from this specific bit, so I tested it and indeed there must
have been a typo:

postgres=# SELECT x, sum(i), sum(sum(i)) OVER (PARTITION BY x) FROM
(VALUES ('a', 1), ('a', 2), ('b', 3)) val (x,i) GROUP BY x;
 x | sum | sum
---+-----+-----
 a |   3 |   3
 b |   3 |   3
(2 rows)

В списке pgsql-general по дате отправления
От: Alvaro Herrera
Дата:
От: Tom Lane
Дата:
FAQ