Aggregation function
Commands: sum(), count(), avg(), max(), min()
Function: statistics, averaging Value, maximum, minimum value
Application scenarios: This type of function is very common and is mainly used for data statistics. It is also applicable in SQL optimization.
Example:
mysql> select max(id) from t_base_user; +---------+ | max(id) | +---------+ | 2 | +---------+ 1 row in set (0.00 sec)
Here is a little trick. If the primary key is increasing in order, when you need how many users there are, you can use max(id) instead of the count(*) function.
The above is the detailed content of How to use aggregate functions in MySQL. For more information, please follow other related articles on the PHP Chinese website!