From: | "Greg Sabino Mullane" <greg(at)turnstep(dot)com> |
---|---|
To: | pgsql-novice(at)postgresql(dot)org |
Subject: | Re: Average over time |
Date: | 2007-03-04 00:20:20 |
Message-ID: | fffb090f2db247acc6c6f0c227322cba@biglumber.com |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-novice |
-----BEGIN PGP SIGNED MESSAGE-----
Hash: RIPEMD160
> ...etc. Obviously, the avg_asum is the average for asum up to the dt
> column's date. My gut feeling is that this can not be done -- but I
> don't know why. Is it possible?
Perhaps something like this:
SELECT thisday, AVG(asum) AS avg_asum
FROM
(SELECT dt, SUM(amount) AS asum FROM transactions GROUP BY dt) AS x,
(SELECT ('2007-01-01'::date+'1 day'::interval*q)::date AS thisday
FROM generate_series(0,10) AS q) AS y
WHERE dt <= thisday
GROUP BY 1 ORDER BY 1;
- --
Greg Sabino Mullane greg(at)turnstep(dot)com
PGP Key: 0x14964AC8 200703031916
http://biglumber.com/x/web?pk=2529DF6AB8F79407E94445B4BC9B906714964AC8
-----BEGIN PGP SIGNATURE-----
iD8DBQFF6g/PvJuQZxSWSsgRAxxVAKC/wV0vh+b9ZTi3hEjEOjGK+4sniACfeSdU
gqlKeLxqxylcZCCbY6OD1wQ=
=srvv
-----END PGP SIGNATURE-----
From | Date | Subject | |
---|---|---|---|
Next Message | sangeetha k.s | 2007-03-04 05:01:55 | Regarding how to run postgresql in FC5 |
Previous Message | Greg Lindstrom | 2007-03-03 22:31:32 | Installing Problem: User Account Exists |