SelectDB Enterprise
参考手册
SQL 函数
聚合函数
BITMAP_UNION_COUNT

BITMAP_UNION_COUNT

描述

计算输入 Bitmap 的并集,返回其基数

语法

BITMAP_UNION_COUNT(<expr>)

参数

参数说明
<expr>支持 BITMAP 的数据类型

返回值

返回 Bitmap 并集的大小,即去重后的元素个数

举例

select dt,page,bitmap_to_string(user_id) from pv_bitmap;
+------+------+---------------------------+
| dt   | page | bitmap_to_string(user_id) |
+------+------+---------------------------+
|    1 | 100  | 100,200,300               |
|    2 | 200  | 300                       |
+------+------+---------------------------+

计算 user_id 的去重值:

select bitmap_union_count(user_id) from pv_bitmap;
+-------------------------------------+
| bitmap_count(bitmap_union(user_id)) |
+-------------------------------------+
|                                   3 |
+-------------------------------------+
© 2025 北京飞轮数据科技有限公司 京ICP备2022004029号 | Apache、Apache Doris 以及相关开源项目名称均为 Apache 基金会商标