# Query Error or other ways

**URL:** <https://forum.inductiveautomation.com/t/query-error-or-other-ways/79501>\
**Category:** General Discussion\
**Created:** [September 22, 2023, 11:20am UTC](https://forum.inductiveautomation.com/t/query-error-or-other-ways/79501 "2023-09-22T11:20:32Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![MarcoP](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@MarcoP](https://forum.inductiveautomation.com/u/MarcoP)\
**Post date:** [September 22, 2023, 11:20am UTC](https://forum.inductiveautomation.com/t/query-error-or-other-ways/79501/1 "2023-09-22T11:20:32Z")

</div>

Hello,  
for some reason a query that is working in query editor, doesn't work if set as a value for a Label.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/112e8a64f6cd77eeee7e05610a837ea05908de87.png)

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

The query:

```auto
select y.OK_Parts-x.OK_Parts Output from (
SELECT t_stamp, Assembly_Actual.OK_Parts, 1 as dummy
FROM Assembly_Actual
where t_stamp in (select min(t_stamp) FROM Assembly_Actual where t_stamp>DateADD(mi, -30, Current_TimeStamp))
) x
join (
SELECT t_stamp,Assembly_Actual.OK_Parts, 1 dummy
FROM Assembly_Actual where t_stamp in (select max(t_stamp) from Assembly_Actual)) y
on x.dummy=y.dummy

```

The source of query is a transaction group created in Ignition  
Are there smarter ways to carry out this part?  
I've been trying with historian but it returns Dataset

Thanks

---

<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:** [September 23, 2023, 7:12pm UTC](https://forum.inductiveautomation.com/t/query-error-or-other-ways/79501/3 "2023-09-23T19:12:39Z")

</div>

What's the error you get ?

---

<div class="post-metadata">

**Author:** ![David\_Stone](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/david_stone/32/79749_2.png) [@David\_Stone](https://forum.inductiveautomation.com/u/David_Stone)\
**Post date:** [September 24, 2023, 12:56am UTC](https://forum.inductiveautomation.com/t/query-error-or-other-ways/79501/4 "2023-09-24T00:56:33Z")

</div>

Try saving and trying it in your browser to see what you get, I have a bunch of queries that error, but they work fine once deployed. It seems to be something in the Binding Preview.

---

<div class="post-metadata">

**Author:** ![MarcoP](https://avatars.discourse-cdn.com/v4/letter/m/b9bd4f/32.png) [@MarcoP](https://forum.inductiveautomation.com/u/MarcoP)\
**Post date:** [September 27, 2023, 8:04am UTC](https://forum.inductiveautomation.com/t/query-error-or-other-ways/79501/5 "2023-09-27T08:04:53Z")

</div>

Thank you for your answer,  
I tried to write the query with "WITH" syntax and seems to work fine;  
Any chances it's possible to make the same query (30 min differential) with Historian?
