update deltasum.md

This commit is contained in:
benbiti 2021-03-23 21:10:26 +08:00
parent 8ac49387c3
commit 67b8f02b93

View File

@ -4,20 +4,66 @@ toc_priority: 141
# deltaSum {#agg_functions-deltasum}
计算连续行之间的差值和。如果差值为负,则忽略。
**语法**
``` sql
deltaSum(value)
```
计算连续行之间的差值和。如果差值为负,则忽略。
`value`必须是整型或浮点类型。
**参数**
示例:
- `value` — 必须是 [整型](../../data-types/int-uint.md) 或者 [浮点型](../../data-types/float.md) 。
**返回值**
- `Integer` or `Float` 型的算术差值和。
**示例**
查询:
``` sql
select deltaSum(arrayJoin([1, 2, 3])); -- => 2
select deltaSum(arrayJoin([1, 2, 3, 0, 3, 4, 2, 3])); -- => 7
select deltaSum(arrayJoin([2.25, 3, 4.5])); -- => 2.25
SELECT deltaSum(arrayJoin([1, 2, 3]));
```
结果:
``` text
┌─deltaSum(arrayJoin([1, 2, 3]))─┐
│ 2 │
└────────────────────────────────┘
```
查询:
``` sql
SELECT deltaSum(arrayJoin([1, 2, 3, 0, 3, 4, 2, 3]));
```
结果:
``` text
┌─deltaSum(arrayJoin([1, 2, 3, 0, 3, 4, 2, 3]))─┐
│ 7 │
└───────────────────────────────────────────────┘
```
查询:
``` sql
SELECT deltaSum(arrayJoin([2.25, 3, 4.5]));
```
结果:
``` text
┌─deltaSum(arrayJoin([2.25, 3, 4.5]))─┐
│ 2.25 │
└─────────────────────────────────────┘
```
## 参见 {#see-also}
- [runningDifference](../../functions/other-functions.md#other_functions-runningdifference)