Okay, Looking at an organizational structure, employees and managers.
I am trying to find all managers who do not have managers that report to them.
The employee table is set up like this:
Employees
----------
employee_id
manager_emp_id
employee_name
Manager_emp_id is the employee_id of this individual's manager.
I've tried using sub-queries to find managers and managers who don't have managers below them, which takes forever and a day to find (out of like 8,000 employees total)
Needless to say, I need to find a better way of finding these managers.
Sample data:
employee_id manager_emp_id Employee_name
111111111 NULL Mr. President
222222222 111111111 Frank Smith
333333333 222222222 Guy Thornton
444444444 222222222 Bill King
555555555 444444444 Mike Black
666666666 444444444 John Reynolds
The query would return the following results:
333333333 222222222 Guy Thornton
444444444 222222222 Bill King
ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise
I am trying to find all managers who do not have managers that report to them.
The employee table is set up like this:
Employees
----------
employee_id
manager_emp_id
employee_name
Manager_emp_id is the employee_id of this individual's manager.
I've tried using sub-queries to find managers and managers who don't have managers below them, which takes forever and a day to find (out of like 8,000 employees total)
Needless to say, I need to find a better way of finding these managers.
Sample data:
employee_id manager_emp_id Employee_name
111111111 NULL Mr. President
222222222 111111111 Frank Smith
333333333 222222222 Guy Thornton
444444444 222222222 Bill King
555555555 444444444 Mike Black
666666666 444444444 John Reynolds
The query would return the following results:
333333333 222222222 Guy Thornton
444444444 222222222 Bill King
ASP, VB, VBS, Cold Fusion, SQL, DTS, T-SQL, PL-SQL, IBM-MQ, Crystal Reports, Crystal Enterprise