2021-02-02 12:00:41 +00:00
|
|
|
|
---
|
2022-08-26 19:07:59 +00:00
|
|
|
|
slug: /zh/sql-reference/aggregate-functions/reference/groupbitor
|
2022-04-10 23:08:18 +00:00
|
|
|
|
sidebar_position: 126
|
2021-02-02 12:00:41 +00:00
|
|
|
|
---
|
|
|
|
|
|
|
|
|
|
# groupBitOr {#groupbitor}
|
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
对于数字序列按位应用 `OR` 。
|
|
|
|
|
|
|
|
|
|
**语法**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
|
|
``` sql
|
|
|
|
|
groupBitOr(expr)
|
|
|
|
|
```
|
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
**参数**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
`expr` – 结果为 `UInt*` 类型的表达式。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
**返回值**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
`UInt*` 类型的值。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
**示例**
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
测试数据::
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
|
|
``` text
|
|
|
|
|
binary decimal
|
|
|
|
|
00101100 = 44
|
|
|
|
|
00011100 = 28
|
|
|
|
|
00001101 = 13
|
|
|
|
|
01010101 = 85
|
|
|
|
|
```
|
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
查询:
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
|
|
``` sql
|
|
|
|
|
SELECT groupBitOr(num) FROM t
|
|
|
|
|
```
|
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
`num` 是包含测试数据的列。
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
2021-02-05 15:50:14 +00:00
|
|
|
|
结果:
|
2021-02-02 12:00:41 +00:00
|
|
|
|
|
|
|
|
|
``` text
|
|
|
|
|
binary decimal
|
|
|
|
|
01111101 = 125
|
|
|
|
|
```
|