I\'m stuck. I\'ve looked for an answer, but can\'t seem to find subtracting time in the same table from two different rows of the same table that fits. I\'m having a difficu
Since you have mentioned PARTITION clause, given below is a version using that clause (haven't tested for syntax, but it should give you the idea)
;WITH EmpData AS
(
SELECT EmpID,
TimeIn,
TimeOut,
ROW_NUMBER() OVER(PARTITION BY EmpId ORDER BY TimeIn) Position
FROM EmployeeTime
)
SELECT a.*
a.TimeOut-b.TimeIn OutTIme
FROM EmpData a LEFT JOIN EmpData b
ON a.EmpId = b.EmpId
AND a.Position-1 = b.Position