COUNTSET takes the target_arg input expression and counts the number of bits within the expression that are either set to 1 or set to 0, depending on the value of target_value_arg.
The target_value_arg parameter only accepts a value of 0 or 1. If a value for target_value_arg is not specified, the default value of 1 is used, and COUNTSET counts the bit values that are set to 1.
If any of the input arguments is NULL, the function returns NULL.