# How to use Executing Aggregations group by with one condition?

**URL:** <https://discuss.elastic.co/t/how-to-use-executing-aggregations-group-by-with-one-condition/41735>\
**Category:** Elasticsearch\
**Created:** [February 15, 2016, 4:26am UTC](https://discuss.elastic.co/t/how-to-use-executing-aggregations-group-by-with-one-condition/41735 "2016-02-15T04:26:12Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![NgocPham](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/ngocpham/32/6242_2.png) [@NgocPham](https://discuss.elastic.co/u/NgocPham)\
**Post date:** [February 15, 2016, 4:26am UTC](https://discuss.elastic.co/t/how-to-use-executing-aggregations-group-by-with-one-condition/41735/1 "2016-02-15T04:26:12Z")

</div>

hi , im newbie in elasticsearch and i have one question. Please help me. Thanks you very much.

im trying use Executing Aggregations to count data in elasticsearch.  
in this link : `https://www.elastic.co/guide/en/elasticsearch/reference/current/_executing_aggregations.html`

it can excute **_first query_** like `SELECT state, COUNT(*) FROM bank GROUP BY state ORDER BY COUNT(*) DESC`

now i want add more condition (employee) like this

`SELECT state, COUNT(*) FROM bank WHERE employee='1' GROUP BY state ORDER BY COUNT(*) DESC`

how to write aggreation?

Thanks for your help

p/s: i see one line is "sum\_other\_doc\_count" in resut when i excute _ **first query.** _ What that mean?.  
i have total 135739 doc, and i have  
"doc\_count\_error\_upper\_bound" : 0,  
"sum\_other\_doc\_count" : 133936.  
i dont know 133936 and 135739 have any relation .

---

<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, 11:16pm UTC](https://discuss.elastic.co/t/how-to-use-executing-aggregations-group-by-with-one-condition/41735/2 "2017-07-05T23:16:29Z")

</div>


