You need to either understand PIVOT / UNPIVOT
http://msdn.microsoft.com/en-us/library/ms177410(v=sql.105).aspx[
^]
or
Create two select statements and use them as derived tables. Then you can join on ID and get your output.
i.e.
Select a.Id, a.Time InTime, b.Time OutTime
from
(select id, time from #Temp where ......) a
inner join
(select id, time from #Temp where ......) b
on a.Id = b.Id