Unless otherwise specified, Aggregate functions ignore null records.
Unless otherwise specified, the aggregate function returns NULL if no matching record is found (the record set is empty.
If you use an aggregate function in a statement that does not use group by, it is equivalent to grouping all rows.
Aggregate (Group
) Functions
Name |
Description |
AVG () |
Return the average value of the argument |
Bit_and () |
Return bitwise AND |
Bit_or () |
Return bitwise OR |
Bit_xor () (V4.1.1) |
Return bitwise XOR |
Count (distinct) |
Return the count of a number of different values |
Count () |
Return a count of the number of rows returned |
Group_concat () (V4.1) |
Return a concatenated string |
Max () |
Return the maximum value |
Min () |
Return the minimum value |
Stddev_pop () (V5.0.3)Stddev () STD () |
Return the population standard deviation |
Stddev_samp () (V5.0.3) |
Return the sample standard deviation |
Sum () |
Return the sum |
Var_pop () (V5.0.3)Variance () (V4.1) |
Return the population standard variance |
Var_samp () (V5.0.3) |
Return the sample variance |
Bit_and () If no rows are returned, it is the largest unsigned bigint INTEGER:18446744073709551615
Bit_or () and bit_xor () are 0 if no rows are returned.
Count (*) returns the data of all rows, including null. If no row is returned, it is 0.
Count (expr) returns all non-null data. If no row is returned, it is 0.
Count (distinct expr) returns all non-null data. If no row is returned, it is 0. It is not compatible with SQL standards. standard SQL returns the number of rows of all different data, including null values
Group by rollup statistical modifier. Equivalent to SQL Server's rollup function!
MySQL's extension to group by in the standard SQL language: columns not in group by can appear in the select list. In this case, the values of the hidden columns of group by are randomly selected. All group columns whose values correspond to group by should be the same! Unless you want! Similarly, there is having processing. Therefore, if you want to avoid this poor MySQL extension, you can setOnly_full_group_by
SQL mode is enabled.