From: | Masaru Sugawara <rk73(at)sea(dot)plala(dot)or(dot)jp> |
---|---|
To: | Mathieu Arnold <mat(at)mat(dot)cc> |
Cc: | pgsql-sql(at)postgresql(dot)org |
Subject: | Re: optimyzing |
Date: | 2002-04-02 15:44:23 |
Message-ID: | 20020403003510.CEE3.RK73@sea.plala.or.jp |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-sql |
On Mon, 01 Apr 2002 19:14:57 +0200
Mathieu Arnold <mat(at)mat(dot)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
From | Date | Subject | |
---|---|---|---|
Next Message | george young | 2002-04-02 16:46:47 | vacuum full fails: Parent tuple was not found[7.2] |
Previous Message | Gordon Clarke | 2002-04-02 12:13:05 | Upgrading PostgreSQL to 7.1.3 |