Re: [GENERAL] how do you write aggregate function

2008-03-11 Thread Martijn van Oosterhout
On Mon, Mar 10, 2008 at 10:01:47AM -0500, Justin wrote: i wish that could work but need to keep track of the individual weights as its a percentage of the total amount of the weight. Unless you have a different meaning of weighted average to me, I don't think you do. AFAIK this would produce

Re: [GENERAL] how do you write aggregate function

2008-03-11 Thread Justin
thanks it now takes 806 ms Martijn van Oosterhout wrote: On Mon, Mar 10, 2008 at 10:01:47AM -0500, Justin wrote: i wish that could work but need to keep track of the individual weights as its a percentage of the total amount of the weight. Unless you have a different meaning of

Re: [GENERAL] how do you write aggregate function

2008-03-10 Thread Martijn van Oosterhout
On Sun, Mar 09, 2008 at 11:40:47AM -0500, Justin wrote: I got the aggregate function for weighted average done. I finely left alone for more than 10 minutes to actual get it written. It takes 2 value input Weight and the Value. it will sum the weighted entries to create the constant

Re: [GENERAL] how do you write aggregate function

2008-03-10 Thread Justin
i wish that could work but need to keep track of the individual weights as its a percentage of the total amount of the weight. I would never have thought the performance of the Array would suck this bad. Martijn van Oosterhout wrote: On Sun, Mar 09, 2008 at 11:40:47AM -0500, Justin wrote:

Re: [GENERAL] how do you write aggregate function

2008-03-10 Thread Justin
A couple of email pointers: * Please don't use language like the Array would suck this bad in lists. I swear like a sailor in person, but it reads *very* badly in email. There are a lot of people on this list who might take offense, since it is their hard work that means that arrays work at

Re: [GENERAL] how do you write aggregate function

2008-03-10 Thread Webb Sprague
On Mon, Mar 10, 2008 at 11:00 AM, Justin [EMAIL PROTECTED] wrote: That comment was not meant to be an insult or disparaging in any way what so ever. If it was taken as such then i'm sorry. I am sure it would have been fine in person, I just think over email it sounded abrasive. But could

Re: [GENERAL] how do you write aggregate function

2008-03-09 Thread Justin
I got the aggregate function for weighted average done. I finely left alone for more than 10 minutes to actual get it written. It takes 2 value input Weight and the Value. it will sum the weighted entries to create the constant then does the normal formula, but does not percentage number

Re: [GENERAL] how do you write aggregate function

2008-03-09 Thread dmp
Array appends are usually a performance hit, as you said. I'm not sure though with PostgreSQL. Why not try it with two arrays and see what happens. At least you would reducing the single array and the eliminating the append. danap. I got the aggregate function for weighted average done. I

Re: [GENERAL] how do you write aggregate function

2008-03-09 Thread Justin
If i use two arrays how do i append new entries into these arrays. array_append only allows for 1 dimension. what other methods are there to add new entries to the array. dmp wrote: Array appends are usually a performance hit, as you said. I'm not sure though with PostgreSQL. Why not try

[Fwd: Re: [GENERAL] how do you write aggregate function]

2008-03-09 Thread Justin
DMP you did give me an idea on how to call the append array sfunc looks like this create or replace function wcost_average_sf (numeric[], numeric, numeric) returns numeric[] as $Body$ begin return array_append(array_append($1, $2), $3); end; $Body$ LANGUAGE 'plpgsql' VOLATILE;

Re: [GENERAL] how do you write aggregate function

2008-03-09 Thread dmp
Justin, I'm really not a expert in this area, on how to code this, or functions in PostgreSQL. All I could offer is some ideas which you might try. Sometimes this is all it takes. Perhaps someone else will respond that might be more helpful. With that said I have read in the documentation the use

Re: [GENERAL] how do you write aggregate function

2008-03-05 Thread btober
Richard Broersma wrote: On Tue, Mar 4, 2008 at 8:44 AM, Justin [EMAIL PROTECTED] wrote: I searched the archive of the mail list and did not find anything Search the documentation. There are a couple great examples posted at

Re: [GENERAL] how do you write aggregate function

2008-03-05 Thread Justin
Thank you i was looking for examples and never thought to look at the user comments. I searched the help files several times but never thought to look at the user comment help online. the help coming that comes with PGAdmin III does not have the user comments. once i get the aggregate

[GENERAL] how do you write aggregate function

2008-03-04 Thread Justin
The help is not real clear nor can i find examples how to write an aggregate function. I searched the archive of the mail list and did not find anything I need to write Weighted Average function so the need to keep track of multiple variables between function calls is must? I see how the

Re: [GENERAL] how do you write aggregate function

2008-03-04 Thread Colin Wetherbee
Justin wrote: The help is not real clear nor can i find examples how to write an aggregate function. Examples: http://www.postgresql.org/docs/8.2/static/xaggr.html I searched the archive of the mail list and did not find anything The online documentation is excellent for these sorts of

Re: [GENERAL] how do you write aggregate function

2008-03-04 Thread Richard Broersma
On Tue, Mar 4, 2008 at 8:44 AM, Justin [EMAIL PROTECTED] wrote: I searched the archive of the mail list and did not find anything I don't know if you've already seen this, but this is the question that I asked a while back: http://archives.postgresql.org/pgsql-general/2007-12/msg00681.php