# Add Nested Query to Existing Nested Query in Report Scripted Data

**URL:** <https://forum.inductiveautomation.com/t/add-nested-query-to-existing-nested-query-in-report-scripted-data/68335>\
**Category:** Ignition\
**Created:** [January 6, 2023, 10:38pm UTC](https://forum.inductiveautomation.com/t/add-nested-query-to-existing-nested-query-in-report-scripted-data/68335 "2023-01-06T22:38:30Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![denji26](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/denji26/32/5805_2.png) [@denji26](https://forum.inductiveautomation.com/u/denji26)\
**Post date:** [January 6, 2023, 10:38pm UTC](https://forum.inductiveautomation.com/t/add-nested-query-to-existing-nested-query-in-report-scripted-data/68335/1 "2023-01-06T22:38:30Z")

</div>

I have had success adding a nested query to an existing datasource using a scripted datasource, but what I have not been able to do is to add a nested query to an existing nested query.

I have a Query Data Source "Parent Data". It has a Nested Query called "ChildData". When I execute the following:

```
from system.report import QueryResults

parentData = data['ParentData']
nestedResults = parentData.getNestedQueryResults()
childData = nestedResults['ChildData']

testHeader = ['col1', 'col2']
testData = [[1,2],[3,4]]
testData = system.dataset.toDataSet(testHeader, testData)

childData.addNestedQueryResults('TestData', [QueryResults(testData)])

```

I get the error "AttributeError: 'array.array' object has no attribute 'addNestedQueryResults'"

I am able to add the testData QueryResults directly to ParentData, but not to ChildData  
ie parentData.addNestedQueryResults('TestData', [QueryResults(testData)]) works properly

---

<div class="post-metadata">

**Author:** ![denji26](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/denji26/32/5805_2.png) [@denji26](https://forum.inductiveautomation.com/u/denji26)\
**Post date:** [January 6, 2023, 10:50pm UTC](https://forum.inductiveautomation.com/t/add-nested-query-to-existing-nested-query-in-report-scripted-data/68335/2 "2023-01-06T22:50:28Z")

</div>

OK, as is usual for me I seem to have figured out the issue as soon as I look for help.

nestedResults['ChildData'] seems to give me a list of QueryResults so I needed nestedResults['ChildData'][0] to access my Nested Query
