# Err - expected field arguments in mean()

**URL:** <https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630>\
**Category:** Welcome & Getting Started\
**Created:** [November 6, 2020, 11:07am UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630 "2020-11-06T11:07:59Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Pratik\_Das\_Baghel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/pratik_das_baghel/32/5698_2.png) [@Pratik\_Das\_Baghel](https://community.influxdata.com/u/Pratik_Das_Baghel)\
**Post date:** [November 6, 2020, 11:07am UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/1 "2020-11-06T11:07:59Z")

</div>

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.

 ![Screenshot (33)](https://us1.discourse-cdn.com/flex023/uploads/influxdata/original/2X/7/744468c9ffe5817267df7eddca252850c60761a6.png)

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [November 9, 2020, 7:17pm UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/2 "2020-11-09T19:17:02Z")

</div>

`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.

---

<div class="post-metadata">

**Author:** ![Pratik\_Das\_Baghel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/pratik_das_baghel/32/5698_2.png) [@Pratik\_Das\_Baghel](https://community.influxdata.com/u/Pratik_Das_Baghel)\
**Post date:** [November 20, 2020, 5:05am UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/3 "2020-11-20T05:05:32Z")

</div>

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).

---

<div class="post-metadata">

**Author:** ![Anaisdg](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/anaisdg/32/6401_2.png) [@Anaisdg](https://community.influxdata.com/u/Anaisdg)\
**Post date:** [November 24, 2020, 8:18pm UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/4 "2020-11-24T20:18:31Z")

</div>

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

> <https://github.com/influxdata/influxdb/issues/8213>
>
> \### Feature Request
> From https://github.com/influxdata/kapacitor/issues/1258
> 
> …
> Consider the following InfluxDB query
> \`\`\`sql
> SELECT mean(\*) FROM ... time \>= '2017-03-13T17:50:00Z' AND time \< '2017-03-13T17:51:00Z'
> \`\`\`
> We will refer to \*\*\`'2017-03-13T17:50:00Z' \`\*\* as the left boundary, lower boundary, or \`tMin\`.
> Similarly, we will refer to \*\*\` '2017-03-13T17:51:00Z'\`\*\* as the right boundary, upper boundary, or \`tMax\`.
> 
> Executing this query against InfluxDB will yield the following result
> \`\`\`
> time mean
> \---- ----
> 2017-03-13T17:50:00Z 8.083532716666666e+08
> \`\`\`
> Note here that this is the \*\*lower boundary\*\* for the time interval. 
> 
> A similar operation in Kapacitor
> \`\`\`
> batch
> |query('SELECT queryDurationNs FROM "\_internal".monitor.queryExecutor')
> .period(1m)
> .every(1m)
> .align()
> |mean('queryDurationNs')
> \`\`\`
> would result in 
> \`\`\`
> time mean
> \---- ----
> 2017-03-13T17:51:00Z 8.083532716666666e+08
> \`\`\`
> Note here that this is the \*\*upper boundary\*\* for the time interval.
> 
> InfluxDB and Kapacitor choose different time boundaries. Kapacitor chooses \`tMax\` and InfluxDB chooses \`tMin\`. The choice between using \`tMax\` or \`tMin\` is somewhat arbitrary for InfluxDB, however the same thing cannot be said for Kapacitor.
> 
> This is because of Kapacitors ability to do joins on overlapping time windows. Meaning if you were to join the mean over the last month with the the mean over the least day, you would need their resulting values to occur at the same time. Using the most recent time, \`tMax\`, to represent both points makes sense.
> 
> This has lead to two issues in the community: \[issue\](https://community.influxdata.com/t/influxdb-cq-vs-kapacitor-batch-vs-kapacitor-stream/202) and https://github.com/influxdata/kapacitor/issues/1257
> 
> \_\_Proposal:\_\_
> Add a handedness clause to InfluxDB
> 
> Similar issues with right and left handed ness of time buckets has come up else where in InfluxDB and therefore it may be worthwhile to implement it here. 
> 
> https://github.com/influxdata/influxdb/issues/7738
> 
> \_\_Current behavior:\_\_ 
> All queries use left handed timestamp for time.
> 
> \_\_Desired behavior:\_\_
> Add a handedness clause to queries so that the left or right handed time values may be specified.
> 
> \_\_Use case:\_\_
> See write up above.

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

> **[timeShift() function | Flux 0.x Documentation](https://docs.influxdata.com/flux/v0.x/stdlib/universe/timeshift/)**
>
> timeShift() adds a fixed duration to time columns.

> **[Manipulate timestamps with Flux | InfluxDB OSS 2.1 Documentation](https://docs.influxdata.com/influxdb/v2.0/query-data/flux/manipulate-timestamps/)**
>
> Use Flux to process and manipulate timestamps.

> **[experimental package | Flux 0.x Documentation](https://docs.influxdata.com/flux/v0.x/stdlib/experimental/)**
>
> The experimental package includes experimental functions and packages.

---

<div class="post-metadata">

**Author:** ![Pratik\_Das\_Baghel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/pratik_das_baghel/32/5698_2.png) [@Pratik\_Das\_Baghel](https://community.influxdata.com/u/Pratik_Das_Baghel)\
**Post date:** [December 9, 2020, 2:33pm UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/6 "2020-12-09T14:33:15Z")

</div>

Hi @Anaisdg @philjb. Actually i am running some 40 - 41 task all at same time, so some of them are showing queue length exceeded error. I tried with retry option for task, also i changed in influx config file - the query size and query concurrency. Set both to 100. Still error is showing. You have any solution for that? Will running some kpis some seconds later will work fine?

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [December 9, 2020, 6:22pm UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/8 "2020-12-09T18:22:31Z")

</div>

You increased the queue length to 100? [InfluxDB configuration options | InfluxDB OSS 2.0 Documentation](https://docs.influxdata.com/influxdb/v2.0/reference/config-options/#query-queue-size)

If you’re at 100, it seems like you’re still running more queries than that at once. Can you spread them out?

---

<div class="post-metadata">

**Author:** ![Pratik\_Das\_Baghel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/pratik_das_baghel/32/5698_2.png) [@Pratik\_Das\_Baghel](https://community.influxdata.com/u/Pratik_Das_Baghel)\
**Post date:** [December 15, 2020, 11:24am UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/10 "2020-12-15T11:24:32Z")

</div>

Hi @philjb @Anaisdg. I have created a task from influxdb ui, where that task is stored inside influxdb container in docker. U have any idea?

---

<div class="post-metadata">

**Author:** ![philjb](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/philjb/32/5405_2.png) [@philjb](https://community.influxdata.com/u/philjb)\
**Post date:** [December 16, 2020, 6:00pm UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/11 "2020-12-16T18:00:42Z")

</div>

@Pratik_Das_Baghel - could you start a new thread? Your question doesn’t seem related to your original question. I don’t fully understand your question either so please add more detail. You can also ask in the Influxdata community slack.

---

<div class="post-metadata">

**Author:** ![Pratik\_Das\_Baghel](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/pratik_das_baghel/32/5698_2.png) [@Pratik\_Das\_Baghel](https://community.influxdata.com/u/Pratik_Das_Baghel)\
**Post date:** [February 3, 2021, 1:58pm UTC](https://community.influxdata.com/t/err-expected-field-arguments-in-mean/16630/12 "2021-02-03T13:58:30Z")

</div>

@Anaisdg @philjb i have a posted a question maybe u could help me.  
link - [Filtering data using tagpass and tagdrop](https://community.influxdata.com/t/filtering-data-using-tagpass-and-tagdrop/18153)
