Received: from sss2.sss.pgh.pa.us (sss.pgh.pa.us [209.114.166.2]) by hub.org (8.10.1/8.10.1) with ESMTP id e89L3ef89593 for ; Sat, 9 Sep 2000 17:03:40 -0400 (EDT) Received: from sss2.sss.pgh.pa.us (tgl@localhost [127.0.0.1]) by sss2.sss.pgh.pa.us (8.9.3/8.9.3) with ESMTP id RAA29845; Sat, 9 Sep 2000 17:03:36 -0400 (EDT) To: Roberto Mello cc: pgsql-sql@Postgresql.org Subject: Re: Creating an aggregate function In-reply-to: <39B9EB44.43CD70B1@cc.usu.edu> References: <39B9EB44.43CD70B1@cc.usu.edu> Comments: In-reply-to Roberto Mello message dated "Sat, 09 Sep 2000 01:48:20 -0600" Date: Sat, 09 Sep 2000 17:03:36 -0400 Message-ID: <29842.968533416@sss.pgh.pa.us> From: Tom Lane X-Archive-Number: 200009/54 Roberto Mello 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