A RetroSearch Logo

Home - News ( United States | United Kingdom | Italy | Germany ) - Football scores

Search Query:

Showing content from https://docs.snowflake.com/en/sql-reference/functions/array_union_agg below:

Website Navigation


ARRAY_UNION_AGG | Snowflake Documentation

ARRAY_UNION_AGG

Returns an ARRAY that contains the union of the distinct values from the input ARRAYs in a column. You can use this to aggregate distinct values in ARRAYs produced by ARRAY_UNIQUE_AGG.

See also:

ARRAY_UNIQUE_AGG , Using Arrays to Compute Distinct Values for Hierarchical Aggregations

Syntax
ARRAY_UNION_AGG( <column> )

Copy

Arguments
column

The column containing the ARRAYs with the distinct values (the ARRAYs produced by ARRAY_UNIQUE_AGG).

Returns

The function returns an ARRAY containing the distinct values from the ARRAYs in column. The values in the ARRAY are in no particular order, and the order is not deterministic.

Note that this function uses multiset semantics, which means that the maximum number of occurrences of an individual value in a single input ARRAY determines the number of occurrences of that value in the output ARRAY. See Examples.

The function ignores NULL values in column and in the ARRAYs in column. If column contains only NULL values or the table containing column is empty, the function returns an empty ARRAY.

Usage notes Examples Aggregation: Union of arrays

The following example illustrates how the function returns the union of distinct values from two ARRAYs:

CREATE TABLE union_test(a array);

INSERT INTO union_test
    SELECT PARSE_JSON('[ 1, 1, 2]')
    UNION ALL
    SELECT PARSE_JSON('[ 1, 2, 3]');

SELECT ARRAY_UNION_AGG(a) FROM union_test;
+-------------------------+
| ARRAY_UNION_AGG(A)      |
+-------------------------+
| [ 1, 1, 2, 3]           |
+-------------------------+

Copy

The operation uses multiset semantics. The value 1 appears twice in the output because it appears twice in one of the input arrays.

See Using Arrays to Compute Distinct Values for Hierarchical Aggregations.


RetroSearch is an open source project built by @garambo | Open a GitHub Issue

Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo

HTML: 3.2 | Encoding: UTF-8 | Version: 0.7.4