跳到主要内容

GROUP_BIT_OR

描述

对单个整数列或表达式中的所有值执行按位 or 运算。

语法

GROUP_BIT_OR(<expr>)

参数

参数说明
<expr>支持类型为 TinyInt,SmallInt,Integer,BigInt,LargeInt。

返回值

返回一个整数值,类型与 相同。如果所有值均为 NULL,则返回 NULL。NULL 值不参与按位运算。

举例

-- setup
create table group_bit(
value int
) distributed by hash(value) buckets 1
properties ("replication_num"="1");

insert into group_bit values
(3),
(1),
(2),
(4),
(NULL);
select group_bit_or(value) from group_bit;
+---------------------+
| group_bit_or(value) |
+---------------------+
| 7 |
+---------------------+
select group_bit_or(value) from group_bit where value is null;
+---------------------+
| group_bit_or(value) |
+---------------------+
| NULL |
+---------------------+