2

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.

  • Additional info:in other words I want to get difference between start and end time. According to example above: ```1573826042491637063 - 1573826041643021709```. – user7545609 Nov 20 '19 at 17:12

1 Answers1

1

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

 select first(ms) - last(ms) from m1;
Steephen
  • 14,645
  • 7
  • 40
  • 47
  • Thank you for your answer, but i've got the following error while trying to perform this request: ```ERR: error parsing query: found ;, expected ) at line 1, char 53``` – user7545609 Nov 18 '19 at 09:35
  • 1
    the first variant was closer to my task. I need tp get diff in time. It means ```1573826042491637063 - 1573826041643021709``` according to example above. Not ``195 - 30``` – user7545609 Nov 20 '19 at 12:57