# Report Nested Query issue

**URL:** <https://forum.inductiveautomation.com/t/report-nested-query-issue/51900>\
**Category:** Ignition\
**Created:** [October 13, 2021, 4:15pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900 "2021-10-13T16:15:46Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![dwoo](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@dwoo](https://forum.inductiveautomation.com/u/dwoo)\
**Post date:** [October 13, 2021, 4:15pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/1 "2021-10-13T16:15:46Z")

</div>

I’m tryin to use the report parameters StartDate and EndDate wihtin a query datasource, which is a nested query. See image for setup

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/0/d/0deb5b0466b25e268618f2e4b068618ee5da5949.png)

The highlighted “?” are supposed to use the report parameters, the first “?” is supposed to refer to the  
parent query result.

I keep getting the error below

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

If I hardcode some dates in like ‘2021/09/13 12:00:00.000’ and ‘2021/10/13 11:03:10.000’, including the single quote, it works just fine.

The return types of the parameters are DATE  
StartDate = dateArithmetic(now(), -8, “hr”)  
EndDate = now()

I’ve tried CASTing the parameters like below

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

it always returns a time out error.

![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/f/d/fd9ec002afd8049543f7becfe58ceb993744e1a0.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/2/b291b7ffec452fcf76f2ad3603c6833c6ff2fcc6.png)

If I try this in the Query Builder or in SSMS it works fine…

Using Ignition 8.16.

---

<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 13, 2021, 4:28pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/2 "2021-10-13T16:28:01Z")

</div>

Your first parameter is blank.

---

<div class="post-metadata">

**Author:** ![dwoo](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@dwoo](https://forum.inductiveautomation.com/u/dwoo)\
**Post date:** [October 13, 2021, 4:39pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/3 "2021-10-13T16:39:40Z")

</div>

When it’s blank it’s supposed to refer to the parent query result…

---

<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 13, 2021, 4:40pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/4 "2021-10-13T16:40:58Z")

</div>

You can’t leave it blank. The parent result is a _ **row** _. You need a column reference to get a _ **value** _ from that row. (And where did you get the idea it could be blank?)

---

<div class="post-metadata">

**Author:** ![dwoo](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@dwoo](https://forum.inductiveautomation.com/u/dwoo)\
**Post date:** [October 13, 2021, 5:06pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/5 "2021-10-13T17:06:47Z")

</div>

Your right, it can not be blank…I thought the parameter was blank when I started testing WITHOUT the date range checking and there were no error reported…going back to that code I see that it defaulted the parameter to the parent SQL query column name…I could’ve swear it was blank yesterday 😃

---

<div class="post-metadata">

**Author:** ![dwoo](https://avatars.discourse-cdn.com/v4/letter/d/bbce88/32.png) [@dwoo](https://forum.inductiveautomation.com/u/dwoo)\
**Post date:** [October 13, 2021, 5:15pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/6 "2021-10-13T17:15:23Z")

</div>

Working now…without CASTing too!

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

---

<div class="post-metadata">

**Author:** ![Rahul\_Bhakte1](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Rahul\_Bhakte1](https://forum.inductiveautomation.com/u/Rahul_Bhakte1)\
**Post date:** [April 23, 2025, 10:30am UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/7 "2025-04-23T10:30:23Z")

</div>

My question is related to the nested query but bit different.

I want to use IN clause in query but while passing parameters I am getting issue.  
It works for single parameter value but not for a string of multiple parameter values. I tried almost all possible ways to form an expression in parameters but didn't get result. What expression syntax am I missing here? Please suggest.  
I am trying hardcoded parameters values here just to check.

**This is main query:**

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

**This is child query:**

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/6/464c85bf1b7dbb25cdedaf924eb8ac1275424338.png)

---

<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:** [April 23, 2025, 12:40pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/8 "2025-04-23T12:40:23Z")

</div>

In most cases, particularly in named queries and in the report builder, placeholder parameters can only take single values, not lists. Where you wish to use `IN`, you must generate multiple question marks. Only scripted "Prep" queries can do this.

---

<div class="post-metadata">

**Author:** ![Rahul\_Bhakte1](https://avatars.discourse-cdn.com/v4/letter/r/c89c15/32.png) [@Rahul\_Bhakte1](https://forum.inductiveautomation.com/u/Rahul_Bhakte1)\
**Post date:** [April 23, 2025, 1:57pm UTC](https://forum.inductiveautomation.com/t/report-nested-query-issue/51900/9 "2025-04-23T13:57:01Z")

</div>

@pturmel Got it !!  
Can you give some example how to prepare the query in my case?
