Page 1 of 1

Duration of value ; a database query question

Posted: Fri Oct 18, 2019 12:37 pm
by Jeffrey
I have a question about getting the duration of a value, which I can’t wrap my head around. It’s probably a simple thing for seasoned query guru’s, but please spare me ; I’m just leaning to use it all.

Ik have a table as attached in the picture.
This table records values whenever the state changes of a sensor (“Vrij” means “Free” and “Bezet” means “Occupied”).

What I want to do, is to get the average duration in which the state is “Bezet”. The question is: How does the query looks like to accomplish this?

(btw. I'm using InfluxDB with Grafana for visualization)