Esto se llama el "problema de las islas" y lo he visto como una solución (crédito Itzik Ben Gan)
select tool_number,
min(time) 'in',
max(time) 'out',
count(*)
from (
select tool_number,
time,
ROW_NUMBER() OVER (ORDER BY time) - ROW_NUMBER() OVER (PARTITION BY Tool_Number ORDER BY time) AS Grp
from #temp
) as a
group by grp, tool_number
order by min(time)