2023-01-02 14:20:21 +00:00
---
slug: /en/sql-reference/aggregate-functions/reference/grouparraylast
2024-06-24 11:52:30 +00:00
sidebar_position: 141
2023-01-02 14:20:21 +00:00
---
# groupArrayLast
Syntax: `groupArrayLast(max_size)(x)`
Creates an array of last argument values.
For example, `groupArrayLast(1)(x)` is equivalent to `[anyLast (x)]` .
2023-09-16 10:25:03 +00:00
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.
2023-01-02 14:20:21 +00:00
**Example**
Query:
```sql
select groupArrayLast(2)(number+1) numbers from numbers(10)
```
Result:
```text
┌─numbers─┐
│ [9,10] │
└─────────┘
```
In compare to `groupArray` :
```sql
select groupArray(2)(number+1) numbers from numbers(10)
```
```text
┌─numbers─┐
│ [1,2] │
└─────────┘
```