# Named query in a transform question

**URL:** <https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555>\
**Category:** Ignition\
**Tags:** namedqueries, perspective, scripting\
**Created:** [June 28, 2024, 8:48pm UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555 "2024-06-28T20:48:38Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [June 28, 2024, 8:48pm UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555/1 "2024-06-28T20:48:39Z")

</div>

Would it be bad practice to run a named query in a transform?

I have a sql query that returns some data and a separate table that I cant inner join. So I want to loop the rows and run a named query to pull in the other aggregate data to be displayed in a table.

I'm torn on the named query in the transform and I wanted to get some other point of views or suggestions.

---

<div class="post-metadata">

**Author:** ![benp](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/benp/32/34073_2.png) [@benp](https://forum.inductiveautomation.com/u/benp)\
**Post date:** [July 1, 2024, 4:22am UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555/2 "2024-07-01T04:22:09Z")

</div>

> [@drewdin](#):
>
> ve a sql query that returns some data and a separate table that I cant inner join. So I want to loop the rows and run a named query to pull in

I'm not sure I understand what you're trying to do here.  
Why don't you create a copy of the named query you're using and add to it the inner join you need?

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 1, 2024, 6:57am UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555/3 "2024-07-01T06:57:33Z")

</div>

Why can't you inner join them ? Is the other table on a different database ?  
You should probably try to fix whatever prevents you from using a simple join, instead of working around it in transforms.

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [July 2, 2024, 2:34am UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555/4 "2024-07-02T02:34:22Z")

</div>

its different data that's not relational but I want it in the same table/rows.

Maybe i could try to link it somehow but I would have to rethink the data entry

---

<div class="post-metadata">

**Author:** ![pascal.fragnoud](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pascal.fragnoud/32/24728_2.png) [@pascal.fragnoud](https://forum.inductiveautomation.com/u/pascal.fragnoud)\
**Post date:** [July 2, 2024, 7:18am UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555/5 "2024-07-02T07:18:40Z")

</div>

How do you merge the data if there's no relation between them ? What's the rule ?

---

<div class="post-metadata">

**Author:** ![bkarabinchak.psi](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/bkarabinchak.psi/32/83567_2.png) [@bkarabinchak.psi](https://forum.inductiveautomation.com/u/bkarabinchak.psi)\
**Post date:** [July 2, 2024, 11:37am UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555/6 "2024-07-02T11:37:19Z")

</div>

Even if a join isn't possible for whatever reason you were going to follow some logic in your transform which could just be a subquery at worst inside your query. The more you let your database handle data manipulation the better off you will be performance wise.

Can you share your database schema and a little sample data?

---

<div class="post-metadata">

**Author:** ![drewdin](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/drewdin/32/3363_2.png) [@drewdin](https://forum.inductiveautomation.com/u/drewdin)\
**Post date:** [July 4, 2024, 3:41am UTC](https://forum.inductiveautomation.com/t/named-query-in-a-transform-question/92555/7 "2024-07-04T03:41:38Z")

</div>

I'll get back with some reply's after the 4th, I appreciate the help!
