Equivalent to Flux/increase() in InfluxDB 3 SQL?

From the flux documentation:

The primary use case for increase() is tracking changes in counter values which may wrap overtime when they hit a threshold or are reset. In the case of a wrap/reset, increase() assumes that the absolute delta between two points is at least their non-negative difference.

So far I haven’t found anything corresponding in the list of SQL functions for InfluxDB 3. What is the best way to deal with wrapped or reset counters?

For InfluxQL there seems to be NON_NEGATIVE_DIFFERENCE() to help with counter resets. How can this be achieved with SQL in InfluxDB 3?

In InfluxDB 3 SQL, there is no direct equivalent to Flux’s increase() or InfluxQL’s NON_NEGATIVE_DIFFERENCE(), but you can replicate it using window functions like LAG() to compute non-negative differences and SUM() OVER() for cumulative totals on counter values.

1 Like

Thanks a lot for your replay. At the moment I am using lag() to calculate the difference and greatest(0, ..) to filter out negatives. Do you have an example or a place where I can look up how to use sum() and over() within my interval to aggregate the positives then?