# Multiple/Join query on same index

**URL:** <https://discuss.elastic.co/t/multiple-join-query-on-same-index/243160>\
**Category:** Elasticsearch\
**Created:** [July 30, 2020, 5:37am UTC](https://discuss.elastic.co/t/multiple-join-query-on-same-index/243160 "2020-07-30T05:37:01Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![mohitbharti](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@mohitbharti](https://discuss.elastic.co/u/mohitbharti)\
**Post date:** [July 30, 2020, 5:37am UTC](https://discuss.elastic.co/t/multiple-join-query-on-same-index/243160/1 "2020-07-30T05:37:01Z")

</div>

```auto
I want to know the Elastic search query for 
select * from 
(Select sum(income) from users where users.name like '%abc%' group by users.address) aResult,
(select count(*), phone number from users where users.name like '%XXX%' group by users.address, users.phone, users.pin ) bResult where aResult.id = bResult.Id

```

---

<div class="post-metadata">

**Author:** ![Christian\_Dahlqvist](https://sea2.discourse-cdn.com/elastic/user_avatar/discuss.elastic.co/christian_dahlqvist/32/4617_2.png) [@Christian\_Dahlqvist](https://discuss.elastic.co/u/Christian_Dahlqvist)\
**Post date:** [July 30, 2020, 5:46am UTC](https://discuss.elastic.co/t/multiple-join-query-on-same-index/243160/2 "2020-07-30T05:46:06Z")

</div>

As Elasticsearch does not support joins I do not think that can be directly translated to a query. If you tell us about your data and what you are looking to achieve someone might be able to help you structure the data and a query to achieve what you are looking for.

---

<div class="post-metadata">

**Author:** ![mohitbharti](https://avatars.discourse-cdn.com/v4/letter/m/c57346/32.png) [@mohitbharti](https://discuss.elastic.co/u/mohitbharti)\
**Post date:** [July 30, 2020, 6:05am UTC](https://discuss.elastic.co/t/multiple-join-query-on-same-index/243160/3 "2020-07-30T06:05:53Z")

</div>

```auto
Stating the actual problem instead of symoblic (user index).
I want to get sum of Laptops distributed by every LOB [field_name column has 'LOB' text and its actual lob name is under column 'FIeld_value'] 
plus under each head [field_name column has text 'HEAD' and field_value has all person heading the LOB's] i need the count of employee's group by region & LOB

------------ sample response ---------------
Lob: Tech1
Count of laptops: 34
details {
	subLob0: {
	name: tech1-subLob0,
	count of resource: 3
	},
	subLob1: {
	name: tech1-subLob1,
	count of resource: 3
	},
	subLob2: {
	name: tech1-subLob2,
	count of resource: 3
	}
}

```

---

<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:** [August 27, 2020, 6:06am UTC](https://discuss.elastic.co/t/multiple-join-query-on-same-index/243160/4 "2020-08-27T06:06:05Z")

</div>

Closed on August 27, 2020, 6:06am UTC

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