Declaration
BIT_XOR(expr)
Description
Returns the bitwise XOR of all bits in expr.
The result type depends on whether the function parameter values are evaluated as binary strings or numbers. Binary string evaluation occurs when a parameter value is of the binary string type and is not a hexadecimal literal, a bit literal, or a NULL literal. Otherwise, numerical computation occurs, converting the parameter value to an unsigned 64-bit integer if necessary.
If no matching rows are found, BIT_XOR() returns a neutral value of the same length as the parameter values (with all bits set to 0).
Unless all values are NULL, a NULL value does not affect the result. In this case, the result is a neutral value of the same length as the parameter values.
Examples
obclient> SELECT year,month,BIT_COUNT(BIT_XOR(1<<day)) AS days FROM tbl1 GROUP BY year,month;
+------+-------+------+
| year | month | days |
+------+-------+------+
| 2021 | 01 | 3 |
| 2021 | 02 | 1 |
+------+-------+------+
2 rows in set