Re: sum() over (partition by order) question - Mailing list pgsql-hackers

From Jaime Casanova
Subject Re: sum() over (partition by order) question
Date
Msg-id 3073cc9b0812311426i7335201aqee10345043c1f460@mail.gmail.com
Whole thread Raw
In response to sum() over (partition by order) question  ("Pavel Stehule" <pavel.stehule@gmail.com>)
List 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 by date:

Previous
From: Tom Lane
Date:
Subject: Re: reloptions and toast tables
Next
From: James Mansion
Date:
Subject: Re: About CMake