mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-28 02:21:59 +00:00
815 B
815 B
slug | sidebar_position |
---|---|
/en/sql-reference/aggregate-functions/reference/grouparraylast | 110 |
groupArrayLast
Syntax: groupArrayLast(max_size)(x)
Creates an array of last argument values.
For example, groupArrayLast(1)(x)
is equivalent to [anyLast (x)]
.
In some cases, you can still rely on the order of execution. This applies to cases when SELECT
comes from a subquery that uses ORDER BY
if the subquery result is small enough.
Example
Query:
select groupArrayLast(2)(number+1) numbers from numbers(10)
Result:
┌─numbers─┐
│ [9,10] │
└─────────┘
In compare to groupArray
:
select groupArray(2)(number+1) numbers from numbers(10)
┌─numbers─┐
│ [1,2] │
└─────────┘