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