On Thu, 16 Sep 2004 15:15:01 -0400, John Holmes
<[EMAIL PROTECTED]> wrote:
> You can't get the average and a count in the same query

Sure you can.

> desc numbers;
+--------+---------+------+-----+---------+-------+
| Field  | Type    | Null | Key | Default | Extra |
+--------+---------+------+-----+---------+-------+
| number | int(11) |      |     | 0       |       |
+--------+---------+------+-----+---------+-------+
1 row in set (0.00 sec)

mysql> select * from numbers;
+--------+
| number |
+--------+
|      1 |
|      2 |
|      1 |
|      2 |
|      1 |
|      2 |
|      1 |
|      2 |
|      1 |
|      2 |
|      3 |
|      4 |
|      3 |
|      4 |
|      3 |
|      4 |
|      3 |
|      4 |
+--------+
18 rows in set (0.00 sec)

mysql> select count(number), avg(number) from numbers;
+---------------+-------------+
| count(number) | avg(number) |
+---------------+-------------+
|            18 |      2.3889 |
+---------------+-------------+
1 row in set (0.00 sec)



-- 
Greg Donald
http://gdconsultants.com/
http://destiney.com/

-- 
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php

Reply via email to