Re: sum() over (partition by order) question

Поиск
Список
Период
Сортировка
От Jaime Casanova
Тема Re: sum() over (partition by order) question
Дата
Msg-id 3073cc9b0812311426i7335201aqee10345043c1f460@mail.gmail.com
обсуждение исходный текст
Ответ на sum() over (partition by order) question  ("Pavel Stehule" <pavel.stehule@gmail.com>)
Список pgsql-hackers
On Wed, Dec 31, 2008 at 4:34 PM, Pavel Stehule <pavel.stehule@gmail.com> wrote:
> Hello
>
> I am play with windows function. I was surprised so these queries has
> different results.
>
> postgres=# select sum(a) over (partition by b), a, b from foo;

AFAIUI, this means one sum per b value, the result in the sum column
will be equivalent to "select sum(a) from foo group by b"

>
> postgres=# select sum(a) over (partition by b order by a), a, b from foo;

and this means something like accumulate the value of a per b value
and for every value of b accumulate per a value... maybe this can be
described better...

don't know exactly if we can imitate this behaviour without window functions

--
Atentamente,
Jaime Casanova
Soporte y capacitación de PostgreSQL
Asesoría y desarrollo de sistemas
Guayaquil - Ecuador
Cel. +59387171157


В списке pgsql-hackers по дате отправления:

Предыдущее
От: Tom Lane
Дата:
Сообщение: Re: reloptions and toast tables
Следующее
От: James Mansion
Дата:
Сообщение: Re: About CMake