# Need multiple group by and sum of one filed

**URL:** <https://discuss.elastic.co/t/need-multiple-group-by-and-sum-of-one-filed/142537>\
**Category:** Elasticsearch\
**Created:** [August 1, 2018, 10:19am UTC](https://discuss.elastic.co/t/need-multiple-group-by-and-sum-of-one-filed/142537 "2018-08-01T10:19:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dilip\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_kumar/32/15459_2.png) [@Dilip\_Kumar](https://discuss.elastic.co/u/Dilip_Kumar)\
**Post date:** [August 1, 2018, 10:19am UTC](https://discuss.elastic.co/t/need-multiple-group-by-and-sum-of-one-filed/142537/1 "2018-08-01T10:19:32Z")

</div>

Hi  
i have write query according to this mysql query.. please suggest :slight\_smile=\>  
select t.operator\_time,t.name\_country,t.name\_operator,t.name\_ads\_publisher,t.name\_campaign,SUM(t.campaign\_price),t.currency\_code  
AS gross\_revenue from traffic\_042018 t group by date(t.operator\_time),  
t.id\_partner, t.id\_ads\_publisher, t.id\_campaign, t.id\_operator

---

<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:** [August 2, 2018, 9:29am UTC](https://discuss.elastic.co/t/need-multiple-group-by-and-sum-of-one-filed/142537/2 "2018-08-02T09:29:44Z")

</div>

Hey,

you should look at aggregations [https://www.elastic.co/guide/en/elasticsearch/reference/6.3/search-aggregations.html](https://www.elastic.co/guide/en/elasticsearch/reference/6.3/search-aggregations.html) - but that sometimes you need to change your document structure compared to SQL database to achieve what you want. You should try indexing some documents into Elasticsearch and then go from there.

---

<div class="post-metadata">

**Author:** ![Dilip\_Kumar](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/dilip_kumar/32/15459_2.png) [@Dilip\_Kumar](https://discuss.elastic.co/u/Dilip_Kumar)\
**Post date:** [August 2, 2018, 9:49am UTC](https://discuss.elastic.co/t/need-multiple-group-by-and-sum-of-one-filed/142537/3 "2018-08-02T09:49:07Z")

</div>

Hi spinsale ,  
Thank you for response, but please suggest what kind of agg will be help for me.. and query structure..

---

<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:** [August 30, 2018, 9:49am UTC](https://discuss.elastic.co/t/need-multiple-group-by-and-sum-of-one-filed/142537/4 "2018-08-30T09:49:09Z")

</div>

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