Re: Creating an aggregate function

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Roberto Mello <rmello(at)cc(dot)usu(dot)edu>
Cc: pgsql-sql(at)Postgresql(dot)org
Subject: Re: Creating an aggregate function
Date: 2000-09-09 21:03:36
Message-ID: 29842.968533416@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Roberto Mello <rmello(at)cc(dot)usu(dot)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 with
initcond1 = '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

In response to

Browse pgsql-sql by date

  From Date Subject
Next Message Max Pyziur 2000-09-10 18:19:08 "ORDER BY" issue - is this a bug?
Previous Message Tom Lane 2000-09-09 16:59:47 Re: [SQL] Porting from mysql to psql (UNIX_TIMESTAMP()?)