Skip to content
ClickHouse Docs
ClickHouse DocsClickHouse Docs

groupArrayIntersect

groupArrayIntersect

引入于:v24.2.0

返回给定数组的交集 (即返回所有给定数组中共同包含的所有元素) 。

语法

groupArrayIntersect(x)

参数

  • x — 参数 (列名或表达式) 。Any

返回值

返回一个数组,其中包含所有数组共有的元素。Array

示例

使用示例

-- Create table with Memory engine
CREATE TABLE numbers (
    a Array(Int32)
) ENGINE = Memory;

-- Insert sample data
INSERT INTO numbers VALUES
    ([1,2,4]),
    ([1,5,2,8,-1,0]),
    ([1,5,7,5,8,2]);

SELECT groupArrayIntersect(a) AS intersection FROM numbers;
┌─intersection─┐
│ [1,2]        │
└──────────────┘
Navigation