fbpx

54. Calculating Date Difference

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.
 

Given the following Employees table. This table contains the employee name, number, manager number, and the employee’s hire date. As you can see, John, whose manager is James, started working 11 months before James. You can also see that Robert, who is also under James’s management, started working 8 months before James:


CREATE TABLE employees
(employeeID int,
employeeName varchar(25),
managerID int,
hireDate date)

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…