跳到主要内容

GROUP_ARRAY_INTERSECT

描述

求出所有行中输入数组中的交集元素,返回一个新的数组

语法

GROUP_ARRAY_INTERSECT(<expr>)

参数

参数说明
<expr>需要求交集的数组列或数组值

返回值

返回一个包含交集结果的数组

举例

select c_array_string from group_array_intersect_test where id in (18, 20);
+------+---------------------------+
| id | col |
+------+---------------------------+
| 1 | ["a", "b", "c", "d", "e"] |
| 2 | ["a", "b"] |
| 3 | ["a", null] |
+------+---------------------------+
select group_array_intersect(col) from group_array_intersect_test;
+----------------------------+
| group_array_intersect(col) |
+----------------------------+
| ["a"] |
+----------------------------+