mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-26 09:32:01 +00:00
6616b670e9
Внес небольшие правки.
2.0 KiB
2.0 KiB
toc_priority |
---|
141 |
deltaSumTimestamp
Adds the difference between consecutive rows. If the difference is negative, it is ignored.
This function is primarily for materialized views that are ordered by some time bucket-aligned timestamp, for example, a toStartOfMinute
bucket. Because the rows in such a materialized view will all have the same timestamp, it is impossible for them to be merged in the "right" order. This function keeps track of the timestamp
of the values it's seen, so it's possible to order the states correctly during merging.
To calculate the delta sum across an ordered collection you can simply use the deltaSum function.
Syntax
deltaSumTimestamp(value, timestamp)
Arguments
value
— Input values, must be some Integer type or Float type or a Date or DateTime.timestamp
— The parameter for order values, must be some Integer type or Float type or a Date or DateTime.
Returned value
- Accumulated differences between consecutive values, ordered by the
timestamp
parameter.
Type: Integer or Float or Date or DateTime.
Example
Query:
SELECT deltaSumTimestamp(value, timestamp)
FROM (SELECT number AS timestamp, [0, 4, 8, 3, 0, 0, 0, 1, 3, 5][number] AS value FROM numbers(1, 10));
Result:
┌─deltaSumTimestamp(value, timestamp)─┐
│ 13 │
└─────────────────────────────────────┘