This advanced SQL exercise is part of the book: Advanced SQL – Practical Techniques and Use-Cases, which includes 100 day-to-day SQL challenges (and solutions), need-to-know advanced features, and key concepts.
A customer service company manages a table that contains the entry and exit hours of employees to and from the attendance management system. For example, as seen below, on January 1st 2016, employee no. 1 logged into the system at 9:30 and logged out at 18:30 (9 hours total). On January 2nd, 2016, employee no. 1 logged into the system at 8:10 and logged out at 18:20 (total of 10.17 hours), and so on.
CREATE TABLE EmpTimeTracker (EmpID int, LogDetails varchar(10) CONSTRAINT LogDetCK CHECK (LogDetails IN ('ClockedIN' , 'ClockedOut')), LogTime datetime) GO