mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-16 04:32:33 +00:00
1.0 KiB
1.0 KiB
slug | sidebar_position |
---|---|
/en/sql-reference/aggregate-functions/reference/grouparraysorted | 146 |
groupArraySorted
Returns an array with the first N items in ascending order.
groupArraySorted(N)(column)
Arguments
-
N
– The number of elements to return. -
column
– The value (Integer, String, Float and other Generic types).
Example
Gets the first 10 numbers:
SELECT groupArraySorted(10)(number) FROM numbers(100)
┌─groupArraySorted(10)(number)─┐
│ [0,1,2,3,4,5,6,7,8,9] │
└──────────────────────────────┘
Gets all the String implementations of all numbers in column:
SELECT groupArraySorted(5)(str) FROM (SELECT toString(number) as str FROM numbers(5));
┌─groupArraySorted(5)(str)─┐
│ ['0','1','2','3','4'] │
└──────────────────────────┘