Err - expected field arguments in mean()

I wanted to run a query whose SQL format is available to me:
“select round(avg (((PUCCHNack + PUSCHNack) / (PUCCHNack+PUCCHAck + PUSCHNack+PUSCHAck)) * 100),2)”.

I converted the above SQL query to influxql format for which I was getting error - expected field arguments in mean():
“select round(mean(ans)) into baghel_kpi from (select sum_value1/sum_value*100 as ans from (select PUCCHNack+PUCCHAck+PUSCHNack+PUSCHAck as sum_value, PUCCHNack+PUSCHNack as sum_value1 from cu_om where time < now())) group by time(1h)”

so I referred some documentation and changed some thing:
"select mean(ans) from (select sum_value1/sum_value*100 as ans from (select PUCCHNack+PUCCHAck+PUSCHNack+PUSCHAck as sum_value, PUCCHNack+PUSCHNack as sum_value1 from cu_om))where time < now() group by time(1h) "

The problem occurring here is for some timestamp i am not getting the mean value even if for that timestamp all field keys are present. In the figure for the timestamp for which no result is coming in that timestamp also the data is present. So i am not sure what is wrong in my query.

time < now() is probably not needed as the continuous query automatically filters to the window of (now(), now() - group_by_interval].

Otherwise, I suggest breaking down your query to see if the individual parts are returning the results you expect.

Thank you, you suggestion worked to break down the query. I am facing one doubt could you help me to solve it - Suppose i wanted to group the data for 8:00 - 9:00 am using group by time(1h). So the value is coming under 8:00 timestamp, i wanted to put the same result in 9:00 timestamp. Is there any way to do that, i tried with offset i.e. group by time(1h,1h). The results are coming same as that of group by time(1h).

Hello @Pratik_Das_Baghel,
Please take a look at this issue:

If you are using 2.x you have a lot of options when it comes to manipulating timestamps:



1 Like