Query Error or other ways

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

The query:

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

What's the error you get ?

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.

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?