This topic describes the bit function BIT_COUNT().

PolarDB-X 1.0 supports only the bit function BIT_COUNT(). The function returns the number of 1s in binary representation of an integer. The function returns NULL if the argument is NULL.

mysql> SELECT BIT_COUNT(29), BIT_COUNT(b'101010');
+--------------+----------------------+
| BIT_COUNT(29) | BIT_COUNT(b'101010') |
+--------------+----------------------+
|            4 |                    3 |
+--------------+----------------------+
1 row in set (0.00 sec)

mysql> SELECT BIT_COUNT(NULL);
+-----------------+
| BIT_COUNT(NULL) |
+-----------------+
|            NULL |
+-----------------+
1 row in set (0.00 sec)