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