# How could I have MySQL sum() and group by clause within my elasticsearch query?

**URL:** <https://discuss.elastic.co/t/how-could-i-have-mysql-sum-and-group-by-clause-within-my-elasticsearch-query/61795>\
**Category:** Elasticsearch\
**Created:** [September 29, 2016, 9:09am UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-sum-and-group-by-clause-within-my-elasticsearch-query/61795 "2016-09-29T09:09:25Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Kulasangar\_Gowrisang](https://avatars.discourse-cdn.com/v4/letter/k/ce73a5/32.png) [@Kulasangar\_Gowrisang](https://discuss.elastic.co/u/Kulasangar_Gowrisang)\
**Post date:** [September 29, 2016, 9:09am UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-sum-and-group-by-clause-within-my-elasticsearch-query/61795/1 "2016-09-29T09:09:25Z")

</div>

I'm trying perform an elasticsearch query as a GET request in order pull data from the index which I created. The data which is in the index is, a table from MySQL DB, configured though logstash.

Here is my request without the IN clause:

**[http://localhost:9200/response\_summary/\_search?q=api:"location"+AND+transactionoperationstatus:"charged"+AND+operatorid='DIALOG'+AND+userid:test+AND+time:"2015-05-27"](http://localhost:9200/response_summary/_search?q=api:%22location%22+AND+transactionoperationstatus:%22charged%22+AND+operatorid='DIALOG'+AND+userid:test+AND+time:%222015-05-27%22)**

In the above, I should be able to append sum(chargeAmount+0) & group by . I tried giving it a search on the web, but couldn't find any solutions.

Any help could be appreaciated.

---

<div class="post-metadata">

**Author:** ![nik9000](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/nik9000/32/44947_2.png) [@nik9000](https://discuss.elastic.co/u/nik9000)\
**Post date:** [September 29, 2016, 6:37pm UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-sum-and-group-by-clause-within-my-elasticsearch-query/61795/2 "2016-09-29T18:37:40Z")

</div>

Have a look at [aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html), in particular the terms and sum aggregations.

---

<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:16pm UTC](https://discuss.elastic.co/t/how-could-i-have-mysql-sum-and-group-by-clause-within-my-elasticsearch-query/61795/3 "2017-07-05T22:16:02Z")

</div>


