num_changes()
The number of times the value changed within the period over which the CounterSummary is calculated. This is determined by evaluating consecutive points. Any change in the value is counted, including counter resets where the counter is reset to zero. This can result in the same adjusted counter value for consecutive points, but is still treated as a change.
num_changes(
summary CounterSummary
) RETURNS BIGINT
For more information about counter aggregation functions, see the hyperfunctions documentation.
Required arguments
Name | Type | Description |
---|---|---|
summary | CounterSummary | The input CounterSummary from a counter_agg call |
Returns
Name | Type | Description |
---|---|---|
num_changes | BIGINT | The number of times the value changed |
Sample usage
SELECT
id,
bucket,
num_changes(summary)
FROM (
SELECT
id,
time_bucket('15 min'::interval, ts) AS bucket,
counter_agg(ts, val) AS summary
FROM foo
GROUP BY id, time_bucket('15 min'::interval, ts)
) t
当前内容版权归 TimescaleDB 或其关联方所有,如需对内容或内容相关联开源项目进行关注与资助,请访问 TimescaleDB .