How to get the sum value from the Influx using a t

2019-09-09 11:15发布

问题:

I used Influx for recording some serial data, and show the reports of these data.

I have a requirement like this:

Get the total sum of the value in the time 07:00 AM to 09:00 AM from 2017-05-11 to 2017-05-17.

In mysql, this is very easy, since you can get this value using one query:

select sum(value) from series where time(time) >= '07:00:00' and time(time) < '09:00:00' and time > '2017-05-11' and time < '2017-05-19'

But in Influx(I'm using 1.0.2 now), I can't see any functions like this, did influx support the query like this?

回答1:

You can use this-

select sum(value) as summed_value from series where time> '2017-03-10 00:00:00' and time<'2017-05-10 00:00:00';

Also if you want to get data using hours also ,in such cases you can use

 select sum(value) as summed_value from series where time> now() - 2400h and time<now() - 1200h;

Let me know,if this solves your problem.



标签: influxdb