# Elastic search aggregation similar to group by

**URL:** <https://discuss.elastic.co/t/elastic-search-aggregation-similar-to-group-by/145648>\
**Category:** Elasticsearch\
**Created:** [August 23, 2018, 5:09am UTC](https://discuss.elastic.co/t/elastic-search-aggregation-similar-to-group-by/145648 "2018-08-23T05:09:32Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![l\_2018](https://avatars.discourse-cdn.com/v4/letter/l/b38774/32.png) [@l\_2018](https://discuss.elastic.co/u/l_2018)\
**Post date:** [August 23, 2018, 5:09am UTC](https://discuss.elastic.co/t/elastic-search-aggregation-similar-to-group-by/145648/1 "2018-08-23T05:09:32Z")

</div>

Hi,

I am trying to get the following sql query to work in elastic search. I am using csv plugin.  
Select name, rowid, sum(amt1), sum(amt2) from tableone where  
Code='code1' group by name, road.

I excuted a similar query in kibana but group by had only one column. It worked.

When i tried executing with multiple column in group by  
I get exception ---- "currently only a single expression can be used with group by" please select one of name, rowid.

Does sql query currently not support multiple column in group by.

Can i get the same result using aggregation, if its possible through aggregation can i get sample aggreation query for the above sql.

Thanks

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [August 24, 2018, 6:45am UTC](https://discuss.elastic.co/t/elastic-search-aggregation-similar-to-group-by/145648/2 "2018-08-24T06:45:20Z")

</div>

Hi @l_2018,  
The timing is perfect: ES 6.4.0 with SQL has this restriction removed, and 6.4.0 has [just been released](https://www.elastic.co/blog/elasticsearch-6-4-0-released).  
For your reference, this is the change that went into 6.4.0: [https://github.com/elastic/elasticsearch/issues/31793](https://github.com/elastic/elasticsearch/issues/31793)

---

<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:** [September 21, 2018, 6:45am UTC](https://discuss.elastic.co/t/elastic-search-aggregation-similar-to-group-by/145648/3 "2018-09-21T06:45:38Z")

</div>

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