# Convert nested query to python scripting

**URL:** <https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737>\
**Category:** Ignition\
**Tags:** ignition81, reporting\
**Created:** [October 2, 2024, 8:35pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737 "2024-10-02T20:35:00Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ayanakoji](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@Ayanakoji](https://forum.inductiveautomation.com/u/Ayanakoji)\
**Post date:** [October 2, 2024, 8:35pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/1 "2024-10-02T20:35:00Z")

</div>

Is there any way you can convert nested query output using python scripting? Because I want all my data to be in script, thanks!

---

<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:** [October 2, 2024, 8:54pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/2 "2024-10-02T20:54:54Z")

</div>

Please share what you have and more clearly describe what you are trying to achieve. Something got lost in translation.

---

<div class="post-metadata">

**Author:** ![Ayanakoji](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@Ayanakoji](https://forum.inductiveautomation.com/u/Ayanakoji)\
**Post date:** [October 2, 2024, 9:13pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/3 "2024-10-02T21:13:34Z")

</div>

sorry, like this for example, i want to convert this nested query to replicate the process but using python scripting

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/7/872e10f45ec4dab04568324466a44ec17412ae01.png)

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [October 2, 2024, 9:22pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/4 "2024-10-02T21:22:44Z")

</div>

That's not a nested query. See [Nested Queries in SQL](https://www.tutorialspoint.com/nested-queries-in-sql) for examples of nested queries.

See also: [system.db | Ignition User Manual](https://docs.inductiveautomation.com/docs/8.1/appendix/scripting-functions/system-db) where you can find all of Ignition's database script functions.

---

<div class="post-metadata">

**Author:** ![josborn](https://avatars.discourse-cdn.com/v4/letter/j/4bbf92/32.png) [@josborn](https://forum.inductiveautomation.com/u/josborn)\
**Post date:** [October 2, 2024, 9:30pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/5 "2024-10-02T21:30:39Z")

</div>

I think that actually is a nested query in the report data tab, but I've never used one so my helpfulness ends there.  
Here's a less cropped screen shot:

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/7/e/7ebc68d8b4a2aa93fc0794866fc8c7f842ab6560.png)

---

<div class="post-metadata">

**Author:** ![Ayanakoji](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@Ayanakoji](https://forum.inductiveautomation.com/u/Ayanakoji)\
**Post date:** [October 2, 2024, 9:35pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/6 "2024-10-02T21:35:48Z")

</div>

yes i was trying to replicate that using python script, my plan is to automate creating new pages for each tank, my goal data output will be like this  
 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/5/9/59b5f37dabe5b1bae71f2e058a5062328a26aa09.png)

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [October 2, 2024, 9:40pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/7 "2024-10-02T21:40:16Z")

</div>

This sounds like a classic XY problem, where you've now described the actual problem you're trying to solve.

Why do you think you need scripting to solve this, or what do you think scripting can do here that "standard" nested reporting queries can't do for you?

---

<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:** [October 2, 2024, 9:46pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/8 "2024-10-02T21:46:19Z")

</div>

Perhaps you are looking for this:

> [@Report with Scripted Nested Data](https://forum.inductiveautomation.com/t/report-with-scripted-nested-data/11801):
>
> The report datasource scripting examples explain how to access the nested data in another key for use constructing a custom dataset. What I don’t see is how to construct nested data that would be suitable for use with a child table in a table group. I have a parent dataset that I’m constructing via script due to annoying limitations of an ancient SQL Server 2000 instance. I need a subquery for each row that could be done with a normal query, but there’s no way to add a regular subquery to a s…

But to echo Paul: Why?

---

<div class="post-metadata">

**Author:** ![Ayanakoji](https://avatars.discourse-cdn.com/v4/letter/a/22d042/32.png) [@Ayanakoji](https://forum.inductiveautomation.com/u/Ayanakoji)\
**Post date:** [October 2, 2024, 9:52pm UTC](https://forum.inductiveautomation.com/t/convert-nested-query-to-python-scripting/96737/9 "2024-10-02T21:52:44Z")

</div>

i just want to try different approach but I guess you're right, thanks for the side thoughts!
