> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# bitmap_union

> Calculates the bitmap union of a set of values after grouping.

Calculates the bitmap union of a set of values after grouping. Common usage scenarios include calculating PV and UV.

## Syntax

```Haskell theme={null}
BITMAP BITMAP_UNION(BITMAP value)
```

## Examples

```sql theme={null}
select page_id, bitmap_union(user_id)
from table
group by page_id;
```

Use this function with bitmap\_count() to obtain the UV of a web page.

```sql theme={null}
select page_id, bitmap_count(bitmap_union(user_id))
from table
group by page_id;
```

If `user_id` is an integer, the above query statement is equivalent to the following:

```sql theme={null}
select page_id, count(distinct user_id)
from table
group by page_id;
```

## keyword

BITMAP\_UNION, BITMAP


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.