Re: BUG #5123: bug in window function "last_value"

From: Hitoshi Harada <umi(dot)tanuki(at)gmail(dot)com>
To: Andrey <andrey(at)ulab(dot)ru>
Cc: Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)com>, pgsql-bugs(at)postgresql(dot)org, Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Subject: Re: BUG #5123: bug in window function "last_value"
Date: 2009-10-16 13:58:47
Message-ID: e08cc0400910160658y68693c6ds92b1c4714d87663c@mail.gmail.com
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-bugs

2009/10/16 Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>:
> Heikki Linnakangas <heikki(dot)linnakangas(at)enterprisedb(dot)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 |           1 |          1
>>> 2 |           1 |          2
>>> 3 |           1 |          3
>>> (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.  If you don't like them, you may need
> to specify a different window frame.
>
>                        regards, tom lane
>

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

--
Hitoshi Harada

In response to

Browse pgsql-bugs by date

  From Date Subject
Next Message Kevin Grittner 2009-10-16 14:33:31 Re: BUG #5118: start-status-insert-fatal
Previous Message Tom Lane 2009-10-16 13:55:28 Re: BUG #5123: bug in window function "last_value"