# Report Script Nested Query

**URL:** <https://forum.inductiveautomation.com/t/report-script-nested-query/37203>\
**Category:** Ignition\
**Created:** [July 29, 2020, 8:00pm UTC](https://forum.inductiveautomation.com/t/report-script-nested-query/37203 "2020-07-29T20:00:07Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [July 29, 2020, 8:00pm UTC](https://forum.inductiveautomation.com/t/report-script-nested-query/37203/1 "2020-07-29T20:00:07Z")

</div>

Need some help/clarification with accessing data in a nested query. I’ve read through the manual and this post: [Report Script Using Nested Query](http://forum.inductiveautomation.com/t/report-script-using-nested-query/11362/5), however I’m thinking either I’m doing something incorrect.

If you have the following:

```auto
Query
   |-Nested Query 1
      |-Nested Query A
      |-Nested Query B

```

If I get the .getCoreResults() for Nested Query 1, I get the results of the query in a dataset. If I then call .getNestedQueryResults() for Nested Query A I get all the results of Nested Query A.

Is there any way in loop through Nested Query 1 and only get the associated nested query results from Nested Query A and B for the result row I’m currently looping through? I need to loop through Nested A and know when row from Nested Query 1 it is associated with so I can make sure that I’m grabbing the right information to associate with this data.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [July 29, 2020, 8:36pm UTC](https://forum.inductiveautomation.com/t/report-script-nested-query/37203/2 "2020-07-29T20:36:14Z")

</div>

Why can you not get them both and _then_ loop?

---

<div class="post-metadata">

**Author:** ![bschroeder](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bschroeder/32/13260_2.png) [@bschroeder](https://forum.inductiveautomation.com/u/bschroeder)\
**Post date:** [July 29, 2020, 8:52pm UTC](https://forum.inductiveautomation.com/t/report-script-nested-query/37203/3 "2020-07-29T20:52:39Z")

</div>

I guess that is what I can’t seem to figure out how to do.

I can’t seem to access the nested query results for Nested Query A or Nested Query B until I’m looping through Nested Query 1.

And then I’m still not sure that will get me what I need.

What I need to do is get the query results for Nested Query 1, and then loop through those results and only get the nested query results that pertain to the row I’m on.
