# Help convert sql to elasticsearch query

**URL:** https://discuss.elastic.co/t/help-convert-sql-to-elasticsearch-query/188843
**Category:** Elasticsearch
**Tags:** elastic-stack-sql
**Created:** [July 4, 2019, 6:26am UTC](https://discuss.elastic.co/t/help-convert-sql-to-elasticsearch-query/188843 "2019-07-04T06:26:56Z")
**Posts on this page:** 2
**Page:** 1

<div class="post-metadata">

### Author: ![111170](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/111170/32/49406_2.png) [@111170](https://discuss.elastic.co/u/111170)
#### Post date: [July 4, 2019, 6:26am UTC](https://discuss.elastic.co/t/help-convert-sql-to-elasticsearch-query/188843/1 "2019-07-04T06:26:56Z")

</div>

i tried to use innerhits but it was not easy.

```auto
select parent.key
     , count(child.key) as cnt
  from Docu parent
  left join Docu child
    on parent.key = child.parentKey
 group by parnet.key
 order by cnt desc

```

please help me ...

---

<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: [August 1, 2019, 6:26am UTC](https://discuss.elastic.co/t/help-convert-sql-to-elasticsearch-query/188843/2 "2019-08-01T06:26:57Z")

</div>

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