Relational Data - Aggregate Functions - Reference - Grouparrayintersect

From FojiSoft Docs
Revision as of 18:43, 28 August 2024 by Chris.Hansen (talk | contribs) (Import ClickHouse Docs: Wed Aug 28 2024 14:43:46 GMT-0400 (Eastern Daylight Time))
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Return an intersection of given arrays (Return all items of arrays, that are in all given arrays).

Syntax

groupArrayIntersect(x)

Arguments

  • x — Argument (column name or expression).

Returned values

  • Array that contains elements that are in all arrays.

Type: Array.

Examples

Consider table numbers:

┌─a──────────────┐
│ [1,2,4]        │
│ [1,5,2,8,-1,0] │
│ [1,5,7,5,8,2]  │
└────────────────┘

Query with column name as argument:

SELECT groupArrayIntersect(a) as intersection FROM numbers;

Result:

┌─intersection──────┐
│ [1, 2]            │
└───────────────────┘