BITAND Function
The BITAND function takes two arguments. The arguments can be any number type value that can be converted to an INT8 value.
Fractional values are truncated before the bit operation. The result is the AND for the two arguments.
If both arguments have the same integer types, the data type of the returned value is the same type as the arguments. If the arguments are of different integer types (for example, INT and INT8), the data type with the greater precision is returned. If the arguments are any other numeric type, such as DECIMAL, SMALLFLOAT, FLOAT, or MONEY, or some combination of those types, the returned data type is DECIMAL(32).
The following example illustrates a query that calls the BITAND function:
select task_id, task_status, decode(bitand(task_status,1), 1, ' Y', ' N') as task_a, decode(bitand(task_status,2), 2, ' Y', ' N') as task_b, decode(bitand(task_status,4), 4, ' Y', ' N') as task_c from tasks;
The following table shows the output of this SELECT statement.
task_id task_status task_a
task_b task_c |
---|
100 1 Y N N 101 1 Y N N 102 2 N Y N 103 4 N N Y 104 6 N Y Y 105 3 Y Y N 106 5 Y N Y 107 7 Y Y Y |