Re: BUG #5123: bug in window function "last_value" - Mailing list pgsql-bugs

From Hitoshi Harada
Subject Re: BUG #5123: bug in window function "last_value"
Date
Msg-id e08cc0400910160658y68693c6ds92b1c4714d87663c@mail.gmail.com
Whole thread Raw
In response to Re: BUG #5123: bug in window function "last_value"  (Tom Lane <tgl@sss.pgh.pa.us>)
List pgsql-bugs
2009/10/16 Tom Lane <tgl@sss.pgh.pa.us>:
> Heikki Linnakangas <heikki.linnakangas@enterprisedb.com> writes:
>> Andrey wrote:
>>> select id, first_value(id) over(order by id), last_value(id) over(order=
 by
>>> id) from t;
>>>
>>> RESULT:
>>> id | first_value | last_value
>>> ----+-------------+------------
>>> 1 | =A0 =A0 =A0 =A0 =A0 1 | =A0 =A0 =A0 =A0 =A01
>>> 2 | =A0 =A0 =A0 =A0 =A0 1 | =A0 =A0 =A0 =A0 =A02
>>> 3 | =A0 =A0 =A0 =A0 =A0 1 | =A0 =A0 =A0 =A0 =A03
>>> (3 rows)
>>>
>>> fist_value - good, last_value - bad
>
>> Looks ok to me. What did you expect?
>
> These *are* the correct answers, since the default window frame runs
> from first row to current row. =A0If you don't like them, you may need
> to specify a different window frame.
>
> =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0 =A0regards, tom lane
>

And it's well-documented. See
http://www.postgresql.org/docs/8.4/static/functions-window.html


--=20
Hitoshi Harada

pgsql-bugs by date:

Previous
From: Tom Lane
Date:
Subject: Re: BUG #5123: bug in window function "last_value"
Next
From: "Kevin Grittner"
Date:
Subject: Re: BUG #5118: start-status-insert-fatal