Re: MySQL query for average records per day

From: Date: Thu, 16 Sep 2004 20:34:24 +0000
Subject: Re: MySQL query for average records per day
References: 1 2 3 4 5  Groups: php.general 
Request: Send a blank email to php-general+get-196911@lists.php.net to get a copy of this message
From: "Greg Donald" <destiney@gmail.com>
mysql> select the_date, count(number), avg(number) from dates group by the_date; +------------+---------------+-------------+ | the_date | count(number) | avg(number) | +------------+---------------+-------------+
| 2004-01-01 |             3 |      2.0000 |
| 2004-01-02 |             4 |      2.5000 |
| 2004-01-03 |             4 |      3.5000 |
+------------+---------------+-------------+ 3 rows in set (0.01 sec)
I say again, I took the request as 1) Number of records per day (which you show, but can ignore the "number" column) and 2) The _overall_ average of those counts, which would be (3+4+4 records) / (3 days) = 3.666 records/day We're arguing the same point, really, and trying to guess what the OP was after... ---John Holmes...

« previous php.general (#196911) next »