Select t1.* ,KPI
from table1 T1
JOIN table2 t2 ON t1.ID = t2.ID
and t2.TIME >= trunc (t1.TIME, 'hh24')
and t2.TIME <= trunc (t1.TIME + 2/24, 'hh24')
Select t1.* , KPI
from table1 T1
JOIN table2 t2 ON t1.ID = t2.ID
and t2.TIME BETWEEN trunc (t1.TIME, 'hh24') and trunc (t1.TIME + 2/24, 'hh24')