# groupBitmap (/docs/reference/sql/aggregate-functions/groupbitmap)



This page describes the RawTree engine binary used to generate this reference. It does not define Query API support. Descriptions retain upstream ClickHouse terminology. See [SQL interface scope](/docs/reference/clickhouse-compatibility#service-interfaces).

Creates a bitmap (bit array) from a column of unsigned integers, then returns the count of unique values (cardinality) in that bitmap.
By appending the `-State` combinator suffix, instead of returning the count, it returns the actual [bitmap object](/reference/functions/regular-functions/bitmap-functions).

**Syntax**

```sql
groupBitmap(expr)
groupBitmapState(expr)
```

**Arguments**

* `expr` — Expression that results in a `UInt*` type. [`UInt*`](/reference/data-types/int-uint)

**Returned value**

Returns the count of type UInt64 type, or a bitmap object when using `-State`. [`UInt64`](/reference/data-types/int-uint)

**Examples**

**Usage example**

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

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

```text title=Response
┌─num─┐
│   3 │
└─────┘
```

*Introduced in version 20.1.0.*
