ClickHouse/docs/en/sql-reference/aggregate-functions/reference/grouparrayintersect.md

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

51 lines
953 B
Markdown
Raw Normal View History

2024-02-05 17:50:05 +00:00
---
slug: /en/sql-reference/aggregate-functions/reference/grouparrayintersect
2024-06-24 12:32:52 +00:00
sidebar_position: 141
2024-02-05 17:50:05 +00:00
---
# groupArrayIntersect
Return an intersection of given arrays (Return all items of arrays, that are in all given arrays).
**Syntax**
``` sql
groupArrayIntersect(x)
```
**Arguments**
- `x` — Argument (column name or expression).
**Returned values**
- Array that contains elements that are in all arrays.
Type: [Array](../../data-types/array.md).
**Examples**
Consider table `numbers`:
``` text
┌─a──────────────┐
│ [1,2,4] │
│ [1,5,2,8,-1,0] │
│ [1,5,7,5,8,2] │
└────────────────┘
```
Query with column name as argument:
``` sql
SELECT groupArrayIntersect(a) as intersection FROM numbers;
```
Result:
```text
┌─intersection──────┐
│ [1, 2] │
└───────────────────┘
```