> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-fix-nav-issues.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> 对无符号整数列执行 bitmap 或聚合计算，返回 UInt64 类型的基数；如果添加后缀 -State，则返回 bitmap 对象

# groupBitmap

<div id="groupBitmap">
  ## groupBitmap
</div>

引入版本：v20.1.0

从无符号整数列创建一个 bitmap (位数组) ，然后返回该 bitmap 中唯一值的个数 (基数) 。
附加 `-State` 组合器后缀后，返回的将不再是计数值，而是实际的 [bitmap 对象](/zh/reference/functions/regular-functions/bitmap-functions)。

**语法**

```sql theme={null}
groupBitmap(expr)
groupBitmapState(expr)
```

**参数**

* `expr` — 结果类型为 `UInt*` 的表达式。[`UInt*`](/zh/reference/data-types/int-uint)

**返回值**

返回 `UInt64` 类型的计数值；使用 `-State` 时，返回 bitmap 对象。[`UInt64`](/zh/reference/data-types/int-uint)

**示例**

**用法示例**

```sql title=Query theme={null}
CREATE TABLE t (UserID UInt32) ENGINE = Memory;
INSERT INTO t VALUES (1), (1), (2), (3);

SELECT groupBitmap(UserID) AS num FROM t;
```

```response title=Response theme={null}
┌─num─┐
│   3 │
└─────┘
```
