RE: [PHP] MySQL query for average records per day

From: Date: Thu, 16 Sep 2004 19:10:12 +0000
Subject: RE: [PHP] MySQL query for average records per day
Groups: php.general 
Request: Send a blank email to php-general+get-196894@lists.php.net to get a copy of this message
[snip] I have a database with a date field in this format 20041016 I'd like to count how many records were made on each day (except today) and average them. Can I do this in one query or will I need to do some more PHP stuff after I get some results? Thanks. Bare bones so far: $sql = "select date1 from $table_name where date1 != '$today'"; [/snip] a. Is a SQL question 2. One query - "SELECT (COUNT(date1)/COUNT(DISTINCT(date1))) AS average FROM $table_name where date1 != '$today'";

« previous php.general (#196894) next »