# elasticsearch-DSL aggregation of part of query result. like select \* from (select \* from table limit 100)

**URL:** <https://discuss.elastic.co/t/elasticsearch-dsl-aggregation-of-part-of-query-result-like-select-from-select-from-table-limit-100/155351>\
**Category:** Elasticsearch\
**Created:** [November 5, 2018, 7:35am UTC](https://discuss.elastic.co/t/elasticsearch-dsl-aggregation-of-part-of-query-result-like-select-from-select-from-table-limit-100/155351 "2018-11-05T07:35:00Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![jacksonxie](https://avatars.discourse-cdn.com/v4/letter/j/71e660/32.png) [@jacksonxie](https://discuss.elastic.co/u/jacksonxie)\
**Post date:** [November 5, 2018, 7:35am UTC](https://discuss.elastic.co/t/elasticsearch-dsl-aggregation-of-part-of-query-result-like-select-from-select-from-table-limit-100/155351/1 "2018-11-05T07:35:00Z")

</div>

Hi,  
ES version: 5.5.2  
System: win7  
problem:  
For SQL: if I want to statistic part of the query result. I can use the SQL with two "select" like:  
select count(distinct col\_name) from (select \* from table limit 100) A group by col\_name;  
For ES-DSL, how can I reach the same goal. Could any one tell me. thks very much.

---

<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:** [December 3, 2018, 7:35am UTC](https://discuss.elastic.co/t/elasticsearch-dsl-aggregation-of-part-of-query-result-like-select-from-select-from-table-limit-100/155351/2 "2018-12-03T07:35:00Z")

</div>

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