I think I've found a solution myself to the moving average problem, so I'm
posting it here in case it works for some others (and so that everybody can
check that I'm doing it right and in the "best" way...)
Basically I'm
1) saving all the couples (timestamp, double) of an aggregation into an arr
Paolo Saudin wrote:
> I use a master table with a "fulldate" field and filled with sequential dates
> to
> fill gaps when meteo data is missing.
I'm sorry, I still don't get it: how can you be sure that postgresql won't call
perl_sliding_mean with not-ordered timestamps-data? I don't mean only
>-Messaggio originale-
>Da: pgsql-general-ow...@postgresql.org
>[mailto:pgsql-general-ow...@postgresql.org] Per conto di Scara Maccai
>Inviato: lunedì 2 febbraio 2009 10.36
>A: Paolo Saudin; pgsql-general@postgresql.org
>Cc: pgsql-general
>Oggetto: Re: R: [GE
> Paolo Saudin wrote:
> For that purpose, a sliding mean calculation I use the following
>
> CREATE TABLE tbl_ayas
> (
> fulldate timestamp without time zone NOT NULL,
> id_1 real, -- temperature
> id_2 real, -- pressure
> ..
> CONSTRAINT tbl_ayas_pkey PRIMARY KEY (fulldate)
> )
>-Messaggio originale-
>Da: pgsql-general-ow...@postgresql.org
>[mailto:pgsql-general-ow...@postgresql.org] Per conto di Scara Maccai
>Inviato: venerdì 30 gennaio 2009 9.36
>A: pgsql-general@postgresql.org
>Oggetto: [GENERAL] complex custom aggregate function
>
>H
Oops,
I meant
group by floor(h_q-x)
instead of
group by (h_q-x)/1
Marc Mamin
> select H,A
> FROM
> (
> select min(h_q) as H, avg(x) as A
> group by h_q/1
> union all
> select min(h_q), avg(x)
> group by (h_q-0.25)/1
> union all
> select min(h_q), avg(x)
> group by (h_q-0.50)/1
> union a
...
HTH,
Marc Mamin
-Original Message-
From: pgsql-general-ow...@postgresql.org on behalf of Scara Maccai
Sent: Fri 1/30/2009 1:45 PM
To: pgsql-general@postgresql.org
Subject: Re: [GENERAL] complex custom aggregate function
Gregory Stark wrote:
> From what I read of your
> descr
Gregory Stark wrote:
> From what I read of your
> description you want to produce one record per input record.
Exactly.
> 8.4 Will have OLAP Window functions which can implement things like
> moving averages.
Using 8.3: could I do it caching all the values "somewhere" in a custom
aggregation
Scara Maccai writes:
> It would be very easy if the input to the custom aggregate function was
> ordered (because I would keep 4 internal counters), but I guess there's
> no way of "forcing" the ordering of the input to the function, right?
You can with a subquery. Something like
SELECT agg
Hi all,
I have a table like:
value int,
quarter timestamp
I need an aggregate function that gives back the maximum "value" using
this algorithm:
AVG of the first hour (first 4 quarters) (AVG0)
same as above, but 1 quarter later (AVG1)
same as above, but n quarters later (AVGn)
result: th
10 matches
Mail list logo