pgsql-bugs(at)postgresql(dot)org writes:
> Now i will create two views:
> P1V:
> select order_id as id1, count(*) as count1 from order_item where state=1 group by order_id;
> P2V:
> select order_id as id2, count(*) as count2 from order_item where state=2 group by order_id;
Grouped views don't work very well in Postgres versions before 7.1.
Time to update ... 7.1.3 is the current release.
regards, tom lane