# SQL - having equivalent query strategy

**URL:** <https://discuss.elastic.co/t/sql-having-equivalent-query-strategy/288954>\
**Category:** Elasticsearch\
**Tags:** eql-elastic-query-language\
**Created:** [November 11, 2021, 6:48am UTC](https://discuss.elastic.co/t/sql-having-equivalent-query-strategy/288954 "2021-11-11T06:48:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![SaitejaParsi](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/saitejaparsi/32/78599_2.png) [@SaitejaParsi](https://discuss.elastic.co/u/SaitejaParsi)\
**Post date:** [November 11, 2021, 6:48am UTC](https://discuss.elastic.co/t/sql-having-equivalent-query-strategy/288954/1 "2021-11-11T06:48:09Z")

</div>

Hi, I have the following query to be converted to DSL and executed on ES. I could not find a suitable aggregation and filter over results of aggregation available out-of-the-box in ES. As an alternative, I am fetching the 'group by count' for each id from ES and filtering the result as a part of my application logic, which is not efficient. Can you suggest any more suitable solution?

```auto
select distinct id from index where colA = "something" group by id having count(*) > 10;

```

**index mapping**  
id : (string)  
colA: (string)

---

<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 9, 2021, 6:48am UTC](https://discuss.elastic.co/t/sql-having-equivalent-query-strategy/288954/2 "2021-12-09T06:48:48Z")

</div>

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