ClickHouse/docs/zh/sql-reference/aggregate-functions/reference/minmap.md

34 lines
830 B
Markdown
Raw Normal View History

2021-02-02 12:00:41 +00:00
---
2022-08-26 19:07:59 +00:00
slug: /zh/sql-reference/aggregate-functions/reference/minmap
2022-04-10 23:08:18 +00:00
sidebar_position: 142
2021-02-02 12:00:41 +00:00
---
# minMap {#agg_functions-minmap}
2021-03-08 10:28:52 +00:00
**语法**
2021-02-02 12:00:41 +00:00
2021-02-22 14:08:23 +00:00
```sql
2021-03-18 16:02:22 +00:00
minMap(key, value)
2021-02-22 14:08:23 +00:00
2021-03-18 16:02:22 +00:00
minMap(Tuple(key, value))
2021-02-22 14:08:23 +00:00
```
2021-02-02 12:00:41 +00:00
2021-02-22 14:08:23 +00:00
根据 `key` 数组中指定的键对 `value` 数组计算最小值。
2021-02-02 12:00:41 +00:00
2021-02-22 14:08:23 +00:00
传递 `key``value` 数组的元组与传递 `key``value` 的两个数组是同义的。
要总计的每一行的 `key``value` (数组)元素的数量必须相同。
返回两个数组组成的元组: 排好序的 `key` 和对应 `key``value` 计算值(最小值)。
2021-02-02 12:00:41 +00:00
2021-03-08 10:28:52 +00:00
**示例**
2021-02-02 12:00:41 +00:00
``` sql
SELECT minMap(a, b)
FROM values('a Array(Int32), b Array(Int64)', ([1, 2], [2, 2]), ([2, 3], [1, 1]))
```
``` text
┌─minMap(a, b)──────┐
│ ([1,2,3],[2,1,1]) │
└───────────────────┘
```