Code:
;with cte as ( select empid, cast(datepart(hh, logtime) as varchar(2)) + ':' + right('0' + cast(datepart(mi, logtime) as varchar(2)), 2) as logtime, row_number() over (partition by empid order by logid) as row from #timing ) select c1.empid as EmployeeID, min(c1.logtime) as InTime, max(c2.logtime) as OutTime, min(isnull(p.punches, '')) as Punches