Re: Windowing functions vs aggregates

Поиск
Список
Период
Сортировка
От Greg Stark
Тема Re: Windowing functions vs aggregates
Дата
Msg-id 4136ffa0904140625s578ac1e4ye784c7a1b5b4c4fa@mail.gmail.com
обсуждение исходный текст
Ответ на Windowing functions vs aggregates  (Teodor Sigaev <teodor@sigaev.ru>)
Ответы Re: Windowing functions vs aggregates  (Tom Lane <tgl@sss.pgh.pa.us>)
Список pgsql-hackers
2009/4/14 Teodor Sigaev <teodor@sigaev.ru>:
> select avg(s)::int4 OVER () from foo;

You can put the cast outside the window expression such as:

postgres=# select s,(avg(s) OVER (range between unbounded preceding
and current row))::int4 from foo;s | avg
---+-----1 |   22 |   23 |   2
(3 rows)


However, I'm kind of confused by that result. Why does the range
"between unbounded preceding and current row" seem to be doing the
average of the whole result set? This is not related to the cast:

postgres=# select s,avg(s) OVER (range between unbounded preceding and
current row) from foo;s |        avg
---+--------------------1 | 2.00000000000000002 | 2.00000000000000003 | 2.0000000000000000
(3 rows)


I haven't recompiled recently and I do recall some bug fixes a while
back. Was this that? I'm recompiling now.






-- 
greg


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

Предыдущее
От: Teodor Sigaev
Дата:
Сообщение: Windowing functions vs aggregates
Следующее
От: Euler Taveira de Oliveira
Дата:
Сообщение: Re: Why isn't stats_temp_directory automatically created?