Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Nested Loop Help..

Author  Topic 

desai.piyush
Starting Member

1 Post

Posted - 2008-08-08 : 20:40:41
Hi
I am little new to those kind of query. Need help. I have one table where it has got user manager relationship.
Fields are like: EmployeeID, EmployeeName, ManagerID
Now, Each user has its one Manager.
I need total count like each manager has how many employees under him. For example employee AA has three employee AA1, AA2, AA3. Now AA1 and AA2 are both manager and under both of them there are 2 employee. So, now I need total count under AA - and it should be 7. And this releation could go like n number of time like
Its like tree view.
Manager (10) - Employee
- Employee
- Manager (7) - Employee
- Manager (5) - Manager (2) - Employee
- Employee
- Employee
- Employee

If I get for one root manager, I can manage rest.

Thanks in advance... for the help.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-08-09 : 02:01:46
You can create a function like this and use it

http://support.microsoft.com/kb/248915
Go to Top of Page
   

- Advertisement -