On Mon, 01 Apr 2002 19:14:57 +0200
Mathieu Arnold <mat@mat.cc> wrote:
> and I can't get a query to have the average of that without having to do
> this subselect.
>
> avg
> ----------------
> 886.6585292820
>
It seems to me that the query can be rewritten without a sub-query,
even though the number of sampling per day is not always kept
at a constant value.
SELECT SUM(traffic)::float / COUNT(DISTINCT date(time))::float / 1024.0 / 86400.0 AS avg
FROM stats WHERE ip = '212.43.217.66' AND date(time) < date('now')
Regards,
Masaru Sugawara