mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-12 09:22:05 +00:00
b9125bb351
* Cleanup DataTypeCustomSimpleAggregateFunction::checkSupportedFunctions() Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Remove unused GroupArrayGeneralListImpl Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> * Introduce groupArrayLast() (useful to store last X values) Also do some refactoring to make code cleaner: - rename insert() to insertWithSampler() (since it is used only for groupArraySample()) - split merge methods into Last/RNG/... Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com> Signed-off-by: Azat Khuzhin <a.khuzhin@semrush.com>
42 lines
776 B
Markdown
42 lines
776 B
Markdown
---
|
|
slug: /en/sql-reference/aggregate-functions/reference/grouparraylast
|
|
sidebar_position: 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`.
|
|
|
|
**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] │
|
|
└─────────┘
|
|
```
|