跳到主要内容
跳到主要内容

groupArrayIntersect

返回给定数组的交集(返回数组中所有数组共有的项目)。

语法

groupArrayIntersect(x)

参数

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

返回值

  • 包含所有数组共有元素的数组。

类型: 数组

示例

考虑表 numbers

┌─a──────────────┐
│ [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] │
└───────────────────┘