ARRAY_AGG
Concatenates input values into an array.
Syntax
ARRAY_AGG(<expr>)
Parameter | Description |
---|---|
<expr> | Expression of any type to be converted to an array. |
Example
Assume we have the following price_list
table:
item | price |
---|---|
apple | 4 |
orange | 11 |
kiwi | 20 |
Running the following query:
SELECT
ARRAY_AGG(item) AS items,
ARRAY_AGG(price) AS prices
FROM
price_list;
Returns: ['apple', 'orange', 'kiwi'], [4,11,20]