# How can I call "extended\_stats" in Elasticsearch 6.4.0 SQL syntax

**URL:** <https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941>\
**Category:** Elasticsearch\
**Created:** [August 24, 2018, 4:15pm UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941 "2018-08-24T16:15:46Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![jam1142](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jam1142](https://discuss.elastic.co/u/jam1142)\
**Post date:** [August 24, 2018, 4:15pm UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941/1 "2018-08-24T16:15:46Z")

</div>

I am excited to hear elasticsearch giving option to write query in SQL syntax but just curious about how can we achieve elasticsearch features like aggregate "extended\_stats" through SQL syntax. I am looking for standard deviation.

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [August 27, 2018, 8:45am UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941/2 "2018-08-27T08:45:23Z")

</div>

Hi @jam1142,  
What do you mean by "aggregating extended\_stats"? If you could explain a bit the use case (not necessarily in technical terms, but more like business usage or user needs), that would help.

Thanks.

---

<div class="post-metadata">

**Author:** ![jam1142](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jam1142](https://discuss.elastic.co/u/jam1142)\
**Post date:** [September 6, 2018, 5:27pm UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941/3 "2018-09-06T17:27:30Z")

</div>

See below in DSL syntax which i am asking for SQL

{  
"size": 0,  
"aggs": {  
"std Batch Requests per sec": {  
"filter": {  
"term": {  
"counter\_name.keyword": "Batch Requests per sec"  
}  
},  
"aggs": {  
"stats\_value": {  
"extended\_stats": {  
"field": "counter\_value"  
}  
}  
}  
}  
}  
}

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [September 7, 2018, 7:34am UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941/4 "2018-09-07T07:34:25Z")

</div>

@jam1142 you won't get the output like ES would give it to you, but there are functions we support that have values extracted from `extended_stats`. Please see [this section of the documentation](https://www.elastic.co/guide/en/elasticsearch/reference/master/sql-functions-aggs.html#_statistics) for those functions.

---

<div class="post-metadata">

**Author:** ![jam1142](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jam1142](https://discuss.elastic.co/u/jam1142)\
**Post date:** [September 7, 2018, 2:52pm UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941/5 "2018-09-07T14:52:38Z")

</div>

Thenka Andrei. I am facing another problem please see if you can help me on this. Here is the link

> [@How can I check index exists in logstash filter and how can get dynamic field from elasticsearch lookup( in filter plugin)](https://discuss.elastic.co/t/how-can-i-check-index-exists-in-logstash-filter-and-how-can-get-dynamic-field-from-elasticsearch-lookup-in-filter-plugin/147616):
>
> Q1: How can i check index exists in "Elasticsearch filter plugin". My situation is taht i am getting old data from elasticsearch to subtract from current record but in case if that index doesn't exist then i want to subtract 0. Currently Its throwing error if index doesn't exist. I need to know how can i check if index exist in elasticsearch filter so i can handle it. Q2: Is there a way to do get filter lookup field by dynamic name like elasticsearch { hosts =\> "localhost:9200" index =\> "pt…

---

<div class="post-metadata">

**Author:** ![Andrei\_Stefan](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/andrei_stefan/32/47533_2.png) [@Andrei\_Stefan](https://discuss.elastic.co/u/Andrei_Stefan)\
**Post date:** [September 10, 2018, 6:34am UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941/6 "2018-09-10T06:34:26Z")

</div>

No problem @jam1142. Unfortunately, I am not familiar enough with the filter plugin in Logstash and it's better to wait for someone monitoring that section to help you further.

---

<div class="post-metadata">

**Author:** ![jam1142](https://avatars.discourse-cdn.com/v4/letter/j/b2d939/32.png) [@jam1142](https://discuss.elastic.co/u/jam1142)\
**Post date:** [September 10, 2018, 6:03pm UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941/7 "2018-09-10T18:03:33Z")

</div>

Thanks Andrei.

---

<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:** [October 8, 2018, 6:03pm UTC](https://discuss.elastic.co/t/how-can-i-call-extended-stats-in-elasticsearch-6-4-0-sql-syntax/145941/8 "2018-10-08T18:03:35Z")

</div>

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