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

# minMap

> minMapコンビネータの使用例です

<div id="description">
  ## 説明
</div>

[`Map`](/ja/reference/functions/aggregate-functions/combinators#-map) コンビネータは、[`min`](/ja/reference/functions/aggregate-functions/min)
関数に適用でき、`minMap`
集約コンビネータ関数を使用して、`Map` 内の各キーに対応する最小値を計算します。

<div id="example-usage">
  ## 使用例
</div>

この例では、時間帯ごとのステータスコードとその件数を格納するテーブルを作成します。
各行には、ステータスコードを対応する件数に関連付けた Map が含まれます。各時間帯内で
各ステータスコードの最小件数を求めるために、`minMap` を使用します。

```sql title="Query" theme={null}
CREATE TABLE metrics(
    date Date,
    timeslot DateTime,
    status Map(String, UInt64)
) ENGINE = MergeTree
ORDER BY ();

INSERT INTO metrics VALUES
    ('2000-01-01', '2000-01-01 00:00:00', (['a', 'b', 'c'], [15, 25, 35])),
    ('2000-01-01', '2000-01-01 00:00:00', (['c', 'd', 'e'], [45, 55, 65])),
    ('2000-01-01', '2000-01-01 00:01:00', (['d', 'e', 'f'], [75, 85, 95])),
    ('2000-01-01', '2000-01-01 00:01:00', (['f', 'g', 'g'], [105, 115, 125]));

SELECT
    timeslot,
    minMap(status),
FROM metrics
GROUP BY timeslot;
```

`minMap` 関数は、各タイムスロット内の各ステータスコードの最小カウントを求めます。例えば:

* タイムスロット '2000-01-01 00:00:00' では:
  * ステータス 'a': 15
  * ステータス 'b': 25
  * ステータス 'c': min(35, 45) = 35
  * ステータス 'd': 55
  * ステータス 'e': 65
* タイムスロット '2000-01-01 00:01:00' では:
  * ステータス 'd': 75
  * ステータス 'e': 85
  * ステータス 'f': min(95, 105) = 95
  * ステータス 'g': min(115, 125) = 115

```response title="Response" theme={null}
   ┌────────────timeslot─┬─minMap(status)───────────────────────┐
1. │ 2000-01-01 00:01:00 │ {'d':75,'e':85,'f':95,'g':115}       │
2. │ 2000-01-01 00:00:00 │ {'a':15,'b':25,'c':35,'d':55,'e':65} │
   └─────────────────────┴──────────────────────────────────────┘
```

<div id="see-also">
  ## 関連項目
</div>

* [`min`](/ja/reference/functions/aggregate-functions/min)
* [`Map コンビネータ`](/ja/reference/functions/aggregate-functions/combinators#-map)
