本文介紹了位函數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)