Good morning at all
i have this problem:
I need to calculate the volume of water in a pump, given the flow rate (contained in a historical tag).
I need to calculate the daily volume (last 24 hours)
I need to calculate the monthly volume (last 30 days)
I need to calculate the annual volume (last 365 days)
Currently the query tag for the calculation of 24h is as follows:
select (sum(my_avg)*3600) from
SELECT avg(sqlt_data_1_2013_05.floatvalue) as my_avg,(from_unixtime(sqlt_data_1_2013_05.t_stamp/1000)) as my_data
where sqlt_data_1_2013_05.tagid = 4856 and
from_unixtime(sqlt_data_1_2013_05.t_stamp/1000) <= (select current_timestamp) and
from_unixtime(sqlt_data_1_2013_05.t_stamp/1000) >= date_sub(curdate(), interval 24 hour)
group by hour(from_unixtime(sqlt_data_1_2013_05.t_stamp/1000))
) as tbl1
How can I modify it, in order to automate the search in the tables above, as regards the monthly volume and yearly volume?
I also have the same problem, I suppose, to the change of month, about the daily calculation