适用范围: NoSQL
返回指定数组表达式中元素的中值。
Syntax
ARRAY_MEDIAN(<array_expr>)
Arguments
Description | |
---|---|
array_expr |
数组表达式。 |
返回类型
返回数值表达式。
例子
以下示例显示了对具有数值的数组使用此函数的结果。
SELECT VALUE {
"case1": ARRAY_MEDIAN([1, 2, 3, 4]),
"case2": ARRAY_MEDIAN([1.0, 2.0, 3.3, 4.7, 7.8]),
"case3": ARRAY_MEDIAN([1, -2.7, 3, -4, undefined]),
"case4": ARRAY_MEDIAN(['abc', 'ABC', 'aBc', 'AbC']),
"case5": ARRAY_MEDIAN([12, 'abc', true, false, null, undefined])
}
[
{
"case1": 2.5,
"case2": 3.3,
"case3": -0.8500000000000001
}
]
注解
- 数组中的元素只能是数字。
- 将忽略任何未定义值。
- 此函数执行完全扫描。