graphing time series data

From: Louis-David Mitterrand <vindex+lists-pgsql-sql(at)apartia(dot)org>
To: pgsql-sql(at)postgresql(dot)org
Subject: graphing time series data
Date: 2010-04-14 14:54:34
Message-ID: 20100414145434.GA13682@apartia.fr
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-sql

Hi,

I have times series data in a 'price' table:

price(id_price, price, id_product, created, modified)

Prices are polled daily and a new 'price' row is created only if the
price of id_product changes, else modified is updated to now().

Now, I'd like to make a graph of average prices per week, per
id_product. As some prices don't vary much, distribution would not be
ideal if I simply 'group by extract(week from p.modified)'.

Ideally I'd generate_series() a list of weeks between min(p.created) and
max(p.modified) and then average prices 'group by p.modified < week'.

What would be the best way to tackle this?

Thanks,

Responses

Browse pgsql-sql by date

  From Date Subject
Next Message Richard Broersma 2010-04-14 15:46:13 Re: graphing time series data
Previous Message Mario Splivalo 2010-04-14 09:48:43 Using CASE in plpgsql causes 'ERROR: cache lookup failed'