База данных: MySQL

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:

o 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

o Binary-string evaluation produces a binary string of the same length
as the argument values. If argument values have unequal lengths, an
.html#error_er_invalid_bitwise_operands_size) error occurs. If the
argument size exceeds 511 bytes, an
.html#error_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

As of MySQL 8.0.12, this function executes as a window function if
over_clause is present. over_clause is as described in

URL: https://dev.mysql.com/doc/refman/8.0/en/aggregate-functions.html