ClickHouse/docs/zh/sql-reference/aggregate-functions/reference/groupbitmap.md

47 lines
550 B
Markdown
Raw Normal View History

2021-02-02 12:00:41 +00:00
---
toc_priority: 128
---
# groupBitmap {#groupbitmap}
2021-02-05 15:50:14 +00:00
从无符号整数列进行位图或聚合计算,返回 `UInt64` 类型的基数,如果添加后缀 `State` ,则返回[位图对象](../../../sql-reference/functions/bitmap-functions.md)。
**语法**
2021-02-02 12:00:41 +00:00
``` sql
groupBitmap(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
`UInt64` 类型的值。
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
UserID
1
1
2
3
```
2021-02-05 15:50:14 +00:00
查询:
2021-02-02 12:00:41 +00:00
``` sql
SELECT groupBitmap(UserID) as num FROM t
```
2021-02-05 15:50:14 +00:00
结果:
2021-02-02 12:00:41 +00:00
``` text
num
3
```