21. Managing Employee Attendance

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)    

To read more

UpScale Analytics is one of the largest platforms in the world for learning SQL by doing, consisting over 300 SQL exercises at different levels (including solutions), by topics, across over 100 different datasets. More…