From: Masaru Sugawara <rk73@sea.plala.or.jp>
To: Mathieu Arnold <mat@mat.cc>
Cc: pgsql-sql@postgresql.org
Subject: Re: optimyzing
Date: Wed, 03 Apr 2002 00:44:23 +0900
Message-ID: <20020403003510.CEE3.RK73@sea.plala.or.jp> (raw)
In-Reply-To: <295475750.1017688497@sauron>
References: <295475750.1017688497@sauron>
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
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: rk73@sea.plala.or.jp, mat@mat.cc
Subject: Re: optimyzing
In-Reply-To: <20020403003510.CEE3.RK73@sea.plala.or.jp>
* 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