# Query that sum balance of different event

**URL:** <https://discuss.elastic.co/t/query-that-sum-balance-of-different-event/157055>\
**Category:** Elasticsearch\
**Created:** [November 16, 2018, 12:41pm UTC](https://discuss.elastic.co/t/query-that-sum-balance-of-different-event/157055 "2018-11-16T12:41:23Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Nikhil\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@Nikhil\_Nambiar](https://discuss.elastic.co/u/Nikhil_Nambiar)\
**Post date:** [November 16, 2018, 12:41pm UTC](https://discuss.elastic.co/t/query-that-sum-balance-of-different-event/157055/1 "2018-11-16T12:41:23Z")

</div>

Hi,  
I need a help on Elasticsearch query solution for an sql query

select t1.\*  
from  
(select \* from abc where event=2003) as t1  
inner join  
(select \* from abc where event =4012) as t2 on t1.c\_id=t2.c\_id  
where t1.balance+t2.balance=0

Is this type of query in elastic search achievable

---

<div class="post-metadata">

**Author:** ![Jaspreet\_Singh](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/jaspreet_singh/32/58296_2.png) [@Jaspreet\_Singh](https://discuss.elastic.co/u/Jaspreet_Singh)\
**Post date:** [November 19, 2018, 5:57pm UTC](https://discuss.elastic.co/t/query-that-sum-balance-of-different-event/157055/2 "2018-11-19T17:57:45Z")

</div>

Can you rephrase your requirement in non sql way?

---

<div class="post-metadata">

**Author:** ![Nikhil\_Nambiar](https://avatars.discourse-cdn.com/v4/letter/n/9fc29f/32.png) [@Nikhil\_Nambiar](https://discuss.elastic.co/u/Nikhil_Nambiar)\
**Post date:** [November 20, 2018, 2:25am UTC](https://discuss.elastic.co/t/query-that-sum-balance-of-different-event/157055/3 "2018-11-20T02:25:43Z")

</div>

I have rephrased the query and I have posted till which point I got success and where it's breaking in below link

> [@Query to display terms associated to a filter aggregation on particular event](https://discuss.elastic.co/t/query-to-display-terms-associated-to-a-filter-aggregation-on-particular-event/157183):
>
> Hi, I need a help for an elastic search query, My query below is as follows { "size":0, "aggs":{ "group-by-customerid":{ "terms":{ "field":"customer\_id.keyword" }, "aggs":{ "card-load":{ "filter":{ "term":{ "Event":2003 } }, "aggs":{ "load-balance":{ "terms":{ "field":"balance" …

---

<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:** [December 18, 2018, 2:25am UTC](https://discuss.elastic.co/t/query-that-sum-balance-of-different-event/157055/4 "2018-12-18T02:25:44Z")

</div>

Closed on December 18, 2018, 2:25am UTC

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