2017-05-19 43 views
0

我用Influx記錄了一些串行數據,並顯示了這些數據的報告。如何使用時間範圍從Influx獲取總和值?

我有這樣的要求:

獲取價值的總和在時間07:00至09:00,從2017年5月11日至2017年5月17日。

在MySQL中,這是很容易的,因爲你可以使用一個查詢得到這個值:

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' 

但在潮(我使用1.0.2現在),我看不出有什麼功能像這樣,influx是否支持這樣的查詢?

回答

0

你可以使用這個 -

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

另外如果你想使用時間也得到數據,在這種情況下,你可以使用

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

讓我知道,如果這能解決你的問題。

+0

不,就像我列出的例子一樣,我想在很多天內獲得總和,而不是隻有一天,比如說,我需要在上午7:00到上午10:00從上午5點到今天,所以它將會是3個範圍,不僅有一個 – guitarpoet

+0

也沒有直接查詢,但是您可以通過組合多個查詢並在每個查詢中使用group by來實現此目的。 – tom

+0

這是不可行的,你的意思是我必須每天搜索這些款項,並將它們彙總在一起? – guitarpoet