> ## Documentation Index
> Fetch the complete documentation index at: https://private-7c7dfe99-mintlify-8a08bda2.mintlify.site/llms.txt
> Use this file to discover all available pages before exploring further.

> タイムスタンプの昇順で時系列をソートします。

# timeSeriesGroupArray

<div id="timeSeriesGroupArray">
  ## timeSeriesGroupArray
</div>

導入バージョン: v25.8.0

時系列データを タイムスタンプ の昇順にソートします。

<Note>
  この関数は Experimental です。`allow_experimental_ts_to_grid_aggregate_function=true` を設定して有効にしてください。
</Note>

**構文**

```sql theme={null}
timeSeriesGroupArray(timestamp, value)
```

**引数**

* `timestamp` — サンプルのタイムスタンプ。[`DateTime`](/ja/reference/data-types/datetime) または [`UInt32`](/ja/reference/data-types/int-uint) または [`UInt64`](/ja/reference/data-types/int-uint)
* `value` — そのタイムスタンプに対応する時系列の値。[`(U)Int*`](/ja/reference/data-types/int-uint) または [`Float*`](/ja/reference/data-types/float) または [`Decimal`](/ja/reference/data-types/decimal)

**戻り値**

タイムスタンプの昇順にソートされた `(timestamp, value)` のタプルの配列を返します。同じタイムスタンプに複数の値がある場合、この関数はその中で最大の値を選択します。[`Array(Tuple(T1, T2))`](/ja/reference/data-types/array)

**例**

**個別の値を使った基本的な使い方**

```sql title=Query theme={null}
WITH
    [110, 120, 130, 140, 140, 100]::Array(UInt32) AS timestamps,
    [1, 6, 8, 17, 19, 5]::Array(Float32) AS values
SELECT timeSeriesGroupArray(timestamp, value)
FROM
(
    SELECT
        arrayJoin(arrayZip(timestamps, values)) AS ts_and_val,
        ts_and_val.1 AS timestamp,
        ts_and_val.2 AS value
);
```

```response title=Response theme={null}
┌─timeSeriesGroupArray(timestamp, value)───────────────┐
│ [(100, 5), (110, 1), (120, 6), (130, 8), (140, 19)]  │
└──────────────────────────────────────────────────────┘
```

**タイムスタンプと値の複数のサンプルを、同じ長さの配列として渡す**

```sql title=Query theme={null}
WITH
    [110, 120, 130, 140, 140, 100]::Array(UInt32) AS timestamps,
    [1, 6, 8, 17, 19, 5]::Array(Float32) AS values
SELECT timeSeriesGroupArray(timestamps, values);
```

```response title=Response theme={null}
┌─timeSeriesGroupArray(timestamps, values)──────────────┐
│ [(100, 5), (110, 1), (120, 6), (130, 8), (140, 19)]   │
└───────────────────────────────────────────────────────┘
```
