pgsql-bugs(at)postgresql(dot)org writes:
> Use a view as opposed to a table and it doesn't work!
This is a longstanding limitation in Postgres views. You can't do
multiple levels of aggregation in a single query, and a view does
not get you past that.
It's fixed for 7.1, however. In current sources I get the expected
answer.
regards, tom lane