本文介绍了位函数BIT_COUNT()。
PolarDB-X 1.0支持一个位函数,即BIT_COUNT(),其返回参数对应的二进制数中1的个数;若参数为NULL,则返回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)