# ElasticSearch Sql aggregation query bugs with SUM function

**URL:** https://discuss.elastic.co/t/elasticsearch-sql-aggregation-query-bugs-with-sum-function/200996
**Category:** Elasticsearch
**Tags:** elastic-stack-sql
**Created:** [September 25, 2019, 8:59am UTC](https://discuss.elastic.co/t/elasticsearch-sql-aggregation-query-bugs-with-sum-function/200996 "2019-09-25T08:59:38Z")
**Posts on this page:** 5
**Page:** 1

<div class="post-metadata">

### Author: ![Johna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johna/32/47016_2.png) [@Johna](https://discuss.elastic.co/u/Johna)
#### Post date: [September 25, 2019, 8:59am UTC](https://discuss.elastic.co/t/elasticsearch-sql-aggregation-query-bugs-with-sum-function/200996/1 "2019-09-25T08:59:38Z")

</div>

HI there,

Sql query is a very fantastic tool offered by EL 7.3. However i cant explain that bug :

When i use SUM with Match , 1 condition, query below works well

POST \_xpack/sql?format=txt  
{  
"query":"SELECT SUM(FlightTimeHour) Avg\_Flight\_Time FROM flights where MATCH(OriginCountry,'AE') "  
}

But if i use 2 or more conditions, SUM and MATCH query below fails :

POST \_xpack/sql?format=txt  
{  
"query":"SELECT SUM(FlightTimeHour) Avg\_Flight\_Time FROM flights where MATCH(OriginCountry,'AE') OR MATCH(OriginCountry,'FR') "  
}

Can someone tell me what is wrong ?

---

<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: [October 1, 2019, 2:31pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-aggregation-query-bugs-with-sum-function/200996/2 "2019-10-01T14:31:15Z")

</div>

Hi @Johna,  
Sorry for replying late. Indeed, this is a bug and I just created [https://github.com/elastic/elasticsearch/issues/47365](https://github.com/elastic/elasticsearch/issues/47365) to track its progress.

---

<div class="post-metadata">

### Author: ![Johna](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/johna/32/47016_2.png) [@Johna](https://discuss.elastic.co/u/Johna)
#### Post date: [October 6, 2019, 12:30pm UTC](https://discuss.elastic.co/t/elasticsearch-sql-aggregation-query-bugs-with-sum-function/200996/3 "2019-10-06T12:30:31Z")

</div>

Hi there,

is there a solution for my problem?

Thanks in advance

---

<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: [October 7, 2019, 7:14am UTC](https://discuss.elastic.co/t/elasticsearch-sql-aggregation-query-bugs-with-sum-function/200996/4 "2019-10-07T07:14:08Z")

</div>

Hi @Johna,  
The bug that I raised has been fixed. It should be available in the next 7.4.1 release.

---

<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: [November 4, 2019, 7:14am UTC](https://discuss.elastic.co/t/elasticsearch-sql-aggregation-query-bugs-with-sum-function/200996/5 "2019-11-04T07:14:13Z")

</div>

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