# Sum() in elastic search Using SQL Plugin

**URL:** <https://discuss.elastic.co/t/sum-in-elastic-search-using-sql-plugin/178511>\
**Category:** Elasticsearch\
**Tags:** elastic-stack-sql\
**Created:** [April 25, 2019, 4:55pm UTC](https://discuss.elastic.co/t/sum-in-elastic-search-using-sql-plugin/178511 "2019-04-25T16:55:42Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![shrutip](https://avatars.discourse-cdn.com/v4/letter/s/e36b37/32.png) [@shrutip](https://discuss.elastic.co/u/shrutip)\
**Post date:** [April 25, 2019, 4:55pm UTC](https://discuss.elastic.co/t/sum-in-elastic-search-using-sql-plugin/178511/1 "2019-04-25T16:55:42Z")

</div>

Hello ,

I am running a sql query on elastic sql plugin but the sum which I am getting is not correct ...

Query is -  
SELECT Field1,Field2,SUM(Field3) st FROM XXX where Field4='ZZZ' and Field5= 'YYY'  
GROUP BY Field1,Field2 .

But the sum which I am getting is more than what it should be ...I did search about it and found if index is corrupted , this could happen and reindexing can help...  
But how to go about it ?

Thanks

---

<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:** [April 26, 2019, 9:07am UTC](https://discuss.elastic.co/t/sum-in-elastic-search-using-sql-plugin/178511/3 "2019-04-26T09:07:42Z")

</div>

@shrutip hey there, any chance you could create a smallish, reproduceable scenario for this issue?  
Another idea would be to use the `_translate` API, see what query ES-SQL is producing and use that to run against Elasticsearch and double check the results.

---

<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:** [May 24, 2019, 9:07am UTC](https://discuss.elastic.co/t/sum-in-elastic-search-using-sql-plugin/178511/4 "2019-05-24T09:07:44Z")

</div>

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