user7545609
user7545609

Reputation: 21

influxDB | get elapsed time between last and first points

How to get difference between the first point in measurement and the last?

Example:

name: m1
time                ID ms
----                -- --
1573826041643021709 1  195
1573826041914872651 2  97
1573826042124354048 3  52
1573826042313151871 4  34
1573826042491637063 5  30

I need to get diff between 1573826041643021709 and 1573826042491637063

select sum(elapsed) from (select elapsed(ms) from m1) shows me expected result, but the way looks complicated and it seems something easier and more elegant should be.

Upvotes: 2

Views: 1516

Answers (1)

Steephen
Steephen

Reputation: 15824

Find first and last point in measurement for the field 'ms' and calculate the difference between them.

 select first(ms) - last(ms) from m1;

Upvotes: 1

Related Questions