Click here to Skip to main content
15,888,091 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi All,

I have a EMP table with columns ID,Name,ManagerID,CTC.I want to display manager
ID,Name and number of employees under him.How do i query.Thanks in advance
Posted

1 solution

Try:
SQL
SELECT e.ID, e.[Name], COUNT(m.ID) FROM EMP e
   JOIN EMP m ON e.ID=m.ManagerID
   GROUP BY e.ID, e.[Name]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900