Re: [SQL] How to aggregates this data

2007-01-11 Thread Bruno Wolff III
On Thu, Jan 11, 2007 at 07:50:19 +0900, John Summerfield <[EMAIL PROTECTED]> wrote: > > I've perused my book (Mastering SQL by Martin Gruber), the postgresql > docs (I have versions here on RHEL (Centos) 4, FC5,6, Debian Testing - > up to 8,1) and I don't see how to choose the entry for the firs

Re: [SQL] How to aggregates this data

2007-01-10 Thread Chad Wagner
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,

Re: [SQL] How to aggregates this data

2007-01-10 Thread Chad Wagner
John, Sub-selects to the rescue. See below. select s1.asx_code, s1.bdate AS date, s1.low, s1.high, s2.open, s3.close, s1.volume from (select asx_code, date_trunc('week', date) AS bdate, max(date) AS edate, min(low) AS low, max(high) AS high, sum(volume) AS volume from sales_summaries

[SQL] How to aggregates this data

2007-01-10 Thread John Summerfield
Now I've figured why I don't get replies, I'm sending again. Intro: I have a table that contains much data like this: SELECT distinct on (date) asx_code,date,open,high,low,close from sales_summaries where asx_code = 'TLSCA' and date >= '2006-12-01' order by date, time desc limit 10; SELECT d