I have a table emp having foll data:
EmpID EmpName MgrID
100 King NULL
101 Smith 100
102 Shine 100
103 Racy 102
Now i want to Display the Employee Name (Boss) and number of Employee (Subordinates) something like this
BOSS SUBORDINATES
BLAKE 5
CLARK 1
FORD 1
JONES 2
KING 3
SCOTT 1
Please guide how to go about querying this table in SQL Server 2008.
Attempted query:
select e.first_name as ename,m.first_name as mname from employees e,employees m where e.manager_id=m.employee_id
EmpID=MgrIDMgrIDandEmpNameEmpNameandcount(*)Translating this to SQL is mechanical: