# Sql aggregation

**URL:** <https://discuss.elastic.co/t/sql-aggregation/83382>\
**Category:** Elasticsearch\
**Created:** [April 24, 2017, 8:37am UTC](https://discuss.elastic.co/t/sql-aggregation/83382 "2017-04-24T08:37:28Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![webb](https://avatars.discourse-cdn.com/v4/letter/w/e56c9b/32.png) [@webb](https://discuss.elastic.co/u/webb)\
**Post date:** [April 24, 2017, 8:37am UTC](https://discuss.elastic.co/t/sql-aggregation/83382/1 "2017-04-24T08:37:28Z")

</div>

hi, my sql like this: SELECT a.\*, (SELECT [b.id](http://b.id), SUM(b.num) FROM table2 AS b GROUP BY [b.id](http://b.id) HAVING [b.id=a.id](http://b.id=a.id)) AS sumNum FROM table1 AS a;  
table2 is nested in table1, how to build dsl?

---

<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 22, 2017, 8:42am UTC](https://discuss.elastic.co/t/sql-aggregation/83382/2 "2017-05-22T08:42:12Z")

</div>

Closed on May 22, 2017, 8:42am UTC

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