Hi guys,
those statements work for me:
select
set(@VAR_MILLIS_MIN ,min(millis)) AS MILLIS_MIN,
set(@VAR_MILLIS_DELTA ,max(MILLIS) - min(MILLIS)) as MILLIS_DELTA
from HISTORICAL.DATAPOINTS D
where D.MILLIS between 100000000 and 101000000 AND PVID=25;
select PVID, floor(((MILLIS-@VAR_MILLIS_MIN)/(@VAR_MILLIS_DELTA+ 0.00000001))*3) AS flooredMillis, min(millis),max(millis),max(numbervalue), min(numbervalue)
from
HISTORICAL.DATAPOINTS
where MILLIS between 100000000 and 101000000 AND PVID=25
group by flooredMillis
order by flooredMillis
But now I would like to merge this functionality into one statement that I can use as prepared statement. Any ideas how this could be done?
The main problem seems to be, that I am using calculated values from the first query in the column definition of the second one...