From: Chad Wagner <chad.wagner@gmail.com>
To: John Summerfield <postgres@herakles.homelinux.org>
Cc: pgsql-sql@postgresql.org
Subject: Re: How to aggregates this data
Date: Wed, 10 Jan 2007 19:38:38 -0500
Message-ID: <81961ff50701101638v68f96965y2310a152d71f3d9@mail.gmail.com> (raw)
In-Reply-To: <81961ff50701101629o265fd555tf64672547261c44@mail.gmail.com>
References: <45A56DAB.1030709@herakles.homelinux.org>
<81961ff50701101629o265fd555tf64672547261c44@mail.gmail.com>
By the way, if you want to include that "incomplete" week before 12/1
(incomplete because it doesn't have a data point for Monday) then you would
do this:
select s1.asx_code, s1.wdate AS date, s1.low, s1.high, s2.open, s3.close,
s1.volume
from (select asx_code, date_trunc('week', date) AS wdate, min(date) AS
bdate, max(date) AS edate, min(low) AS low, max(high) AS high, SUM(volume)
AS volume
from sales_summaries
group by asx_code, date_trunc('week', date)) s1, sales_summaries s2,
sales_summaries s3
where s1.bdate = s2.date
and s1.asx_code=s2.asx_code
and s1.edate = s3.date
and s1.asx_code=s3.asx_code;
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Reply to all the recipients using the --to and --cc options:
reply via email
To: pgsql-sql@postgresql.org
Cc: chad.wagner@gmail.com, postgres@herakles.homelinux.org
Subject: Re: How to aggregates this data
In-Reply-To: <81961ff50701101638v68f96965y2310a152d71f3d9@mail.gmail.com>
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox