Re: [HACKERS] Windowing functions vs aggregates

2009-04-14 Thread Tom Lane
Greg Stark writes: > 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? That's what it's supposed to do. "Current row" really includes all peers of the current row in the window f

Re: [HACKERS] Windowing functions vs aggregates

2009-04-14 Thread Tom Lane
Teodor Sigaev writes: > Cast of aggregate's type works: > # select avg(s)::int4 from foo; > but that doesn't work for with new windowing functions interface: > # select avg(s)::int4 OVER () from foo; > ERROR: syntax error at or near "OVER" > LINE 1: select avg(s)::int4 OVER () from foo; > Is th

Re: [HACKERS] Windowing functions vs aggregates

2009-04-14 Thread Greg Stark
2009/4/14 Teodor Sigaev : > 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 | 2 2 | 2 3 | 2 (3 rows) However, I'm

[HACKERS] Windowing functions vs aggregates

2009-04-14 Thread Teodor Sigaev
Cast of aggregate's type works: # select avg(s)::int4 from foo; but that doesn't work for with new windowing functions interface: # select avg(s)::int4 OVER () from foo; ERROR: syntax error at or near "OVER" LINE 1: select avg(s)::int4 OVER () from foo; Is that intentional? -- Teodor Sigaev