select a.AttendanceID,a.CheckTime,a.ActionType,b.FullName from EmployeeAttendance a join EmployeeDetails b on a.EmployeeID=b.EmployeeID where AttendanceID in (select top 1 AttendanceID from EmployeeAttendance b
where a.EmployeeID=b.EmployeeID order by AttendanceID desc)and a.ActionType='i'