# Stats aggregation query on multiple fields

**URL:** https://discuss.elastic.co/t/stats-aggregation-query-on-multiple-fields/55387
**Category:** Elasticsearch
**Created:** [July 13, 2016, 8:51am UTC](https://discuss.elastic.co/t/stats-aggregation-query-on-multiple-fields/55387 "2016-07-13T08:51:37Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![nrmohta](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nrmohta/32/120038_2.png) [@nrmohta](https://discuss.elastic.co/u/nrmohta)
#### Post date: [July 13, 2016, 8:51am UTC](https://discuss.elastic.co/t/stats-aggregation-query-on-multiple-fields/55387/1 "2016-07-13T08:51:37Z")

</div>

Hi,

We are using stats aggregation in our project like below

```auto
{
    "aggs" : {
        "grades_stats" : { "stats" : { "field" : "grade" } }
    }
}

```

For some new requirement we want to make use of multiple fields in stats query.  
I have read documents on internet regarding it and my understanding is we can use only 1 field  
in stats query.  
Is there any other way to meet our new requirement?

---

<div class="post-metadata">

### Author: ![jpountz](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jpountz/32/45836_2.png) [@jpountz](https://discuss.elastic.co/u/jpountz)
#### Post date: [July 13, 2016, 3:18pm UTC](https://discuss.elastic.co/t/stats-aggregation-query-on-multiple-fields/55387/2 "2016-07-13T15:18:13Z")

</div>

You could use `copy_to` in your mappings in order to merge data from multiple fields into a single field. It would be the fastest option but would require reindexing.

Or you could merge the stats on client side, see eg. [http://stackoverflow.com/questions/1480626/merging-two-statistical-result-sets](http://stackoverflow.com/questions/1480626/merging-two-statistical-result-sets).

---

<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: [July 5, 2017, 10:36pm UTC](https://discuss.elastic.co/t/stats-aggregation-query-on-multiple-fields/55387/3 "2017-07-05T22:36:00Z")

</div>


