# How to write a efficient ES query for the below SQL query?

**URL:** https://discuss.elastic.co/t/how-to-write-a-efficient-es-query-for-the-below-sql-query/215599
**Category:** Elasticsearch
**Created:** [January 19, 2020, 5:53am UTC](https://discuss.elastic.co/t/how-to-write-a-efficient-es-query-for-the-below-sql-query/215599 "2020-01-19T05:53:45Z")
**Posts on this page:** 1
**Showing post:** 2

<div class="post-metadata">

### Author: ![aravindputrevu](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/aravindputrevu/32/24816_2.png) [@aravindputrevu](https://discuss.elastic.co/u/aravindputrevu)
#### Post date: [January 19, 2020, 6:47am UTC](https://discuss.elastic.co/t/how-to-write-a-efficient-es-query-for-the-below-sql-query/215599/2 "2020-01-19T06:47:05Z")

</div>

If you have your documents ingested appropriately like mentioned [here](https://www.elastic.co/guide/en/elasticsearch/reference/current/_mapping_concepts_across_sql_and_elasticsearch.html), you could use the [translate](https://www.elastic.co/guide/en/elasticsearch/reference/current/sql-translate.html) endpoint of Elasticsearch SQL and convert the SQL query to equivalent Query DSL.

--  
Aravind

---

_[View the full topic](https://discuss.elastic.co/t/how-to-write-a-efficient-es-query-for-the-below-sql-query/215599)._
