content_image/694101.jpg
<img src='content_image/694101.jpg'>

Unless otherwise stated, aggregate functions ignore NULL  values. 

If you use an aggregate function in a statement containing no GROUP BY  clause, it is equivalent to grouping on all rows. For more information, see Section 12.20.3, “MySQL Handling of GROUP BY” . 

Most aggregate functions can be used as window functions. Those that can be used this way are signified in their syntax description by [ over_clause ] , representing an optional OVER  clause. over_clause is described in Section 12.21.2, “Window Function Concepts and Syntax” , which also includes other information about window function usage. 

For numeric arguments, the variance and standard deviation functions return a DOUBLE  value. The SUM() and AVG()  functions return a DECIMAL  value for exact-value arguments (integer or DECIMAL ), and a DOUBLE  value for approximate-value arguments ( FLOAT  or DOUBLE ). 

The SUM()  and AVG()  aggregate functions do not work with temporal values. (They convert the values to numbers, losing everything after the first nonnumeric character.) To work around this problem, convert to numeric units, perform the aggregate operation, and convert back to a temporal value. Examples: 

SELECT SEC_TO_TIME(SUM(TIME_TO_SEC( time_col ))) FROM tbl_name ; SELECT FROM_DAYS(SUM(TO_DAYS( date_col ))) FROM tbl_name ; 

Functions such as SUM()  or AVG()  that expect a numeric argument cast the argument to a number if necessary. For SET  or ENUM  values, the cast operation causes the underlying numeric value to be used. 

The BIT_AND() , BIT_OR() , and BIT_XOR()  aggregate functions perform bit operations. Prior to MySQL 8.0, bit functions and operators required BIGINT  (64-bit integer) arguments and returned BIGINT  values, so they had a maximum range of 64 bits. Non- BIGINT  arguments were converted to BIGINT  prior to performing the operation and truncation could occur. 

In MySQL 8.0, bit functions and operators permit binary string type arguments ( BINARY , VARBINARY , and the BLOB  types) and return a value of like type, which enables them to take arguments and produce return values larger than 64 bits. For discussion about argument evaluation and result types for bit operations, see the introductory discussion in Section 12.13, “Bit Functions and Operators” . 

• AVG([DISTINCT] expr ) [ over_clause ] 

