Cannot build plan for query

with
temp1 (endTime,startTime) as (select Max(TIME_PARSE(ts)) endTime , MIN(TIME_PARSE(ts)) startTime from data_source where __time >= TIMESTAMP ‘2013-10-16 00:00:00’ AND __time <=TIMESTAMP ‘2025-10-17 00:00:00’ group by TIME_FLOOR(__time,‘PT1H’)),
temp2(maxValue,minValue) as (select Max(value) maxValue , MIN(value) minValue from data_source where __time >= TIMESTAMP ‘2013-10-16 00:00:00’ AND __time <=TIMESTAMP ‘2025-10-17 00:00:00’ group by TIME_FLOOR(__time,‘PT1H’))

select value,ts from data_source m1, temp2 t2 where m1.tagvalue=t2.maxValue

Could you please tell what wrong i am doing here.

with
temp1 (endTime,startTime) as (select Max(TIME_PARSE(ts)) endTime , MIN(TIME_PARSE(ts)) startTime from data_source where __time >= TIMESTAMP ‘2013-10-16 00:00:00’ AND __time <=TIMESTAMP ‘2025-10-17 00:00:00’ group by TIME_FLOOR(__time,‘PT1H’)),
temp2(maxValue,minValue) as (select Max(value) maxValue , MIN(value) minValue from data_source where __time >= TIMESTAMP ‘2013-10-16 00:00:00’ AND __time <=TIMESTAMP ‘2025-10-17 00:00:00’ group by TIME_FLOOR(__time,‘PT1H’))

select value,ts from data_source m1, temp2 t2 where m1.value=t2.maxValue

Could you please tell what wrong i am doing here.

You have multiple values in the from clause of the select (select value,ts from data_source m1, temp2 t2) that is not supported
It looks like you are trying to get the time of the max value (is temp1 ever used?) you could best achieve this with two queries, one to get the values (temp2) and a second to do the filter.

Actually i wanted to solve probelm

Interval wise Max Value and corresponding time, Min Value and Corresponding time , Start value and corresponding time and End Value and corresponding time.

Above example was just try.

In mysql if execute following query

select time, max(value) from table

then it give me max value and corresponding time. Same i was expecting from druid.