# Error on running influx query

**URL:** <https://community.influxdata.com/t/error-on-running-influx-query/1156>\
**Category:** Systems\
**Created:** [June 1, 2017, 5:41pm UTC](https://community.influxdata.com/t/error-on-running-influx-query/1156 "2017-06-01T17:41:50Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [June 1, 2017, 5:41pm UTC](https://community.influxdata.com/t/error-on-running-influx-query/1156/1 "2017-06-01T17:41:50Z")

</div>

I am trying to extract the mean of used\_percent and display the value of host in the table using api, But it shows me the error:

error parsing query: mixing aggregate and non-aggregate queries is not supported

I am running this query:  
select mean(used\_percent),host from mem where time \> now() - 5m group by host

Please guide.

---

<div class="post-metadata">

**Author:** ![mark](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mark/32/778_2.png) [@mark](https://community.influxdata.com/u/mark)\
**Post date:** [June 1, 2017, 5:56pm UTC](https://community.influxdata.com/t/error-on-running-influx-query/1156/2 "2017-06-01T17:56:50Z")

</div>

> [@errishma](#):
>
> select mean(used\_percent),host from mem where time \> now() - 5m group by host

Change that to `select mean(used_percent) from mem where time > now() - 5m group by host`. You’re already grouping by host so you don’t need to select it as well.

---

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [June 1, 2017, 6:18pm UTC](https://community.influxdata.com/t/error-on-running-influx-query/1156/3 "2017-06-01T18:18:07Z")

</div>

Thanks Mark, this query does not show the host name as output. I need to show hostname and the corresponding mean value in table.

---

<div class="post-metadata">

**Author:** ![mark](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/mark/32/778_2.png) [@mark](https://community.influxdata.com/u/mark)\
**Post date:** [June 1, 2017, 9:28pm UTC](https://community.influxdata.com/t/error-on-running-influx-query/1156/4 "2017-06-01T21:28:44Z")

</div>

The grouped by tags are present in the JSON response under `results.series.tags` rather than `results.series.values`.

If that doesn’t work for you, there’s probably a way to make this work with subqueries. Off the top of my head, I’m not sure what that would look like.

---

<div class="post-metadata">

**Author:** ![errishma](https://avatars.discourse-cdn.com/v4/letter/e/f07891/32.png) [@errishma](https://community.influxdata.com/u/errishma)\
**Post date:** [June 1, 2017, 10:45pm UTC](https://community.influxdata.com/t/error-on-running-influx-query/1156/5 "2017-06-01T22:45:41Z")

</div>

Thank you Mark.

I am using this link: [Query response object: ResultSet — InfluxDB 5.3.1 documentation](http://influxdb-python.readthedocs.io/en/latest/resultset.html#)  
to get the results.

E.g if I am running this:  
rs = cli.query(“select mean(used\_percent) from mem where time \> now() - 5m group by host”)  
mem\_points = list(rs.get\_points(measurement=‘men’))  
print mem\_points

it shows only values, how can I use tags here

---

<div class="post-metadata">

**Author:** ![ezquat](https://sea1.discourse-cdn.com/flex023/user_avatar/community.influxdata.com/ezquat/32/5083_2.png) [@ezquat](https://community.influxdata.com/u/ezquat)\
**Post date:** [May 31, 2019, 1:29am UTC](https://community.influxdata.com/t/error-on-running-influx-query/1156/6 "2019-05-31T01:29:23Z")

</div>

I’m also hitting this problem, and although I gather that the grouped-by tag names might be available in the JSON results, I don’t think that helps me because I’m trying to use this form of query as a subquery. I want to use the tag name in the outer query, so I want to pass that name through to the outer query. Certainly the query has meaning, so it’s unfortunate that it isn’t supported. I’d like to lobby for its support.

(FWIW, I have a related problem when using selectors on two fields, and again trying to pass a tag name through to an outer query. That is, this bug: [Cannot select tag when using set functions · Issue #7802 · influxdata/influxdb · GitHub](https://github.com/influxdata/influxdb/issues/7802))
