ClickHouse/docs/en/sql-reference/aggregate-functions/reference/deltasum.md

20 lines
445 B
Markdown
Raw Normal View History

---
toc_priority: 141
---
# deltaSum {#agg_functions-deltasum}
Syntax: `deltaSum(value)`
Adds the differences between consecutive rows. If the difference is negative, it is ignored.
2021-02-10 10:28:22 +00:00
`value` must be some integer or floating point type.
Example:
```sql
2021-02-04 05:50:35 +00:00
select deltaSum(arrayJoin([1, 2, 3])); -- => 2
select deltaSum(arrayJoin([1, 2, 3, 0, 3, 4, 2, 3])); -- => 7
2021-02-10 10:28:22 +00:00
select deltaSum(arrayJoin([2.25, 3, 4.5])); -- => 2.25
```