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)

Would you like to read more?