Counts the number of bits set to 1 in the binary representation of a number.
BIGINTDiperbarui: 13 Jun 2026BIT_COUNT(n)The number whose bits will be counted
1 SELECT BIT_COUNT(5) AS bits; 2 -- 5 = 101 in binary = 2 bits set
5 in binary is 101 (2 bits set to 1).
1 SELECT user_id, 2 permissions, 3 BIT_COUNT(permissions) AS permission_count 4 FROM users;
Counts the number of active permission flags.
1 SELECT product_id, 2 BIT_COUNT(features) AS enabled_features 3 FROM products 4 WHERE BIT_COUNT(features) >= 5;
Products with at least 5 active features.
Sudah paham BIT_COUNT? Latih langsung di browser
Latihan interaktif, langsung di browser.