Returns the average value of expr . The DISTINCT  option can be used to return the average of the distinct values of expr . 

If there are no matching rows, AVG()  returns NULL . 

This function executes as a window function if over_clause  is present. over_clause  is as described in Section 12.21.2, “Window Function Concepts and Syntax” ; it cannot be used with DISTINCT . 

mysql> SELECT student_name, AVG(test_score) FROM student GROUP BY student_name; 

• BIT_AND( expr ) [ over_clause ] 

Returns the bitwise AND  of all bits in expr . 

The result type depends on whether the function argument values are evaluated as binary strings or numbers: 

•Binary-string evaluation occurs when the argument values have a binary string type, and the argument is not a hexadecimal literal, bit literal, or NULL  literal. Numeric evaluation occurs otherwise, with argument value conversion to unsigned 64-bit integers as necessary. 

•Binary-string evaluation produces a binary string of the same length as the argument values. If argument values have unequal lengths, an ER_INVALID_BITWISE_OPERANDS_SIZE  error occurs. If the argument size exceeds 511 bytes, an ER_INVALID_BITWISE_AGGREGATE_OPERANDS_SIZE error occurs. Numeric evaluation produces an unsigned 64-bit integer. 

If there are no matching rows, BIT_AND()  returns a neutral value (all bits set to 1) having the same length as the argument values. 

NULL  values do not affect the result unless all values are NULL . In that case, the result is a neutral value having the same length as the argument values. 

For more information discussion about argument evaluation and result types, see the introductory discussion in Section 12.13, “Bit Functions and Operators” . 

If BIT_AND()  is invoked from within the mysql  client, binary string results display using hexadecimal notation, depending on the value of the --binary-as-hex . For more information about that option, see Section 4.5.1, “mysql — The MySQL Command-Line Client” . 

As of MySQL 8.0.12, this function executes as a window function if over_clause  is present. over_clause  is as described in Section 12.21.2, “Window Function Concepts and Syntax” . 

• BIT_OR( expr ) [ over_clause ] 

Returns the bitwise OR  of all bits in expr . 

The result type depends on whether the function argument values are evaluated as binary strings or numbers: 

•Binary-string evaluation occurs when the argument values have a binary string type, and the argument is not a hexadecimal literal, bit literal, or NULL  literal. Numeric evaluation occurs otherwise, with argument value conversion to unsigned 64-bit integers as necessary. 

•Binary-string evaluation produces a binary string of the same length as the argument values. If argument values have unequal lengths, an ER_INVALID_BITWISE_OPERANDS_SIZE  error occurs. 

