I would like get help in the following Data , we have hand punch machines which saves exit and entry log , each exit and entry log stores a different row for an employee id
EMP ID | EntryTime | ExitTime
11769 2015-02-01 08:00:00 NULL
11769 NULL 2015-02-01 13:00:00
use a subquery in such cases.
SELECT DISTINCT at1.empId ,at1.EntryTime , (SELECT MIN(a2.ExitTime) FROM attendance at2 WHERE at1.empId = at2.empId AND at2.ExitTime >at1.EntryTime ) ExitTime FROM attendance at1 WHERE at1.EntryTime IS NOT NULL