# Is it possible to do this in one search: select count(1), sum(field1) from table where condition group by field2

**URL:** <https://discuss.elastic.co/t/is-it-possible-to-do-this-in-one-search-select-count-1-sum-field1-from-table-where-condition-group-by-field2/29082>\
**Category:** Elasticsearch\
**Created:** [September 11, 2015, 2:02am UTC](https://discuss.elastic.co/t/is-it-possible-to-do-this-in-one-search-select-count-1-sum-field1-from-table-where-condition-group-by-field2/29082 "2015-09-11T02:02:41Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![makeyang](https://avatars.discourse-cdn.com/v4/letter/m/f05b48/32.png) [@makeyang](https://discuss.elastic.co/u/makeyang)\
**Post date:** [September 11, 2015, 2:02am UTC](https://discuss.elastic.co/t/is-it-possible-to-do-this-in-one-search-select-count-1-sum-field1-from-table-where-condition-group-by-field2/29082/1 "2015-09-11T02:02:41Z")

</div>

without count(1), it is sample, but is it possible if with count and do it in one search?

---

<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 11, 2015, 12:36pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-this-in-one-search-select-count-1-sum-field1-from-table-where-condition-group-by-field2/29082/2 "2015-09-11T12:36:33Z")

</div>

See [aggregations](https://www.elastic.co/guide/en/elasticsearch/reference/current/search-aggregations.html). They do exactly this.

---

<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:50pm UTC](https://discuss.elastic.co/t/is-it-possible-to-do-this-in-one-search-select-count-1-sum-field1-from-table-where-condition-group-by-field2/29082/3 "2017-07-05T23:50:44Z")

</div>


