# It is possible to calculate something like avg(a) + avg(b) group by c

**URL:** <https://discuss.elastic.co/t/it-is-possible-to-calculate-something-like-avg-a-avg-b-group-by-c/109872>\
**Category:** Elasticsearch\
**Created:** [December 1, 2017, 3:27am UTC](https://discuss.elastic.co/t/it-is-possible-to-calculate-something-like-avg-a-avg-b-group-by-c/109872 "2017-12-01T03:27:51Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![izhangzhihao](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/izhangzhihao/32/24900_2.png) [@izhangzhihao](https://discuss.elastic.co/u/izhangzhihao)\
**Post date:** [December 1, 2017, 3:27am UTC](https://discuss.elastic.co/t/it-is-possible-to-calculate-something-like-avg-a-avg-b-group-by-c/109872/1 "2017-12-01T03:27:51Z")

</div>

I don't know how to make my explanation, for example in sql

```
SELECT c,avg(a) + avg(b) as count FROM name group by c;

```

It is possible to write using in elasticsearch? Thanks!

---

<div class="post-metadata">

**Author:** ![spinscale](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/spinscale/32/25011_2.png) [@spinscale](https://discuss.elastic.co/u/spinscale)\
**Post date:** [December 1, 2017, 7:54am UTC](https://discuss.elastic.co/t/it-is-possible-to-calculate-something-like-avg-a-avg-b-group-by-c/109872/2 "2017-12-01T07:54:45Z")

</div>

I do think so (my SQL skills are very rusty after years of Elasticsearch), but a `terms` aggregation with two nested `avg` aggregations might be what you are searching for.

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/elastic/original/3X/1/a/1ac57faf039f6b580b3f104ef42a2a89e41014de.png) [@system](https://discuss.elastic.co/u/system)\
**Post date:** [December 29, 2017, 7:54am UTC](https://discuss.elastic.co/t/it-is-possible-to-calculate-something-like-avg-a-avg-b-group-by-c/109872/3 "2017-12-29T07:54:51Z")

</div>

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.
