Changes

MySQL Data Aggregation Functions

705 bytes added, 19:07, 24 October 2007
Using the MySQL AVG() Function
| 95.4 |
+-----------+
1 row in set (0.00 sec)
</pre>
 
== Using the MySQL AVG() Function ==
 
The MySQL COUNT() function adds the number of rows that match the filter criteria specified in a SELECT statement. For example, to count the number of rows with a price in our sample table:
 
<pre>
mysql> SELECT COUNT(*) FROM products;
+----------+
| price_ag |
+----------+
| 8 |
+----------+
1 row in set (0.00 sec)
</pre>
 
Similarly, we can restrict our criteria to list the number of products beneath a specific price threshold:
 
<pre>
mysql> SELECT COUNT(prod_price) AS low_price_items FROM products WHERE prod_price < 200;
+-----------------+
| low_price_items |
+-----------------+
| 5 |
+-----------------+
1 row in set (0.00 sec)
</pre>