Roberto Mello <rmello@cc.usu.edu> writes:
> and our output was:
> date_id | n_sessions_day | members | non_members
> ---------+----------------+-----------+-------------
> 1 | 500 | 30 | 136394044
> 2 | 2000 | 136394612 | 136394612
In current sources I get the expected results if I write the
CREATE AGGREGATE commands withinitcond1 = '0');
Although the parser will accept unquoted integers as initcond
inputs, it looks like something downstream is mishandling them,
resulting in an invalid initial value entered into the pg_aggregate
entry for the aggregate.
I'll look into fixing that for 7.1, but in the meantime try putting
quotes around the initial values.
BTW, your agg_if_member function is not very good, because if it gets
more than one input row with member_p = 1 then the result is order-
dependent. You don't want that.
regards, tom lane