mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-17 11:52:27 +00:00
1.1 KiB
1.1 KiB
sidebar_position |
---|
108 |
groupArraySorted
Returns an array with the first N items in ascending order.
groupArraySorted(N)(column)
Arguments
N
– The number of elements to return.
If the parameter is omitted, default value 10 is used.
Arguments
column
– The value.expr
— Optional. The field or expresion to sort by. If not set values are sorted by themselves.
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] │
└──────────────────────────────┘
Or the last 10:
SELECT groupArraySorted(10)(number, -number) FROM numbers(100)
┌─groupArraySorted(10)(number, negate(number))─┐
│ [99,98,97,96,95,94,93,92,91,90] │
└──────────────────────────────────────────────┘