SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Group directory
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

kwacz23
Starting Member

44 Posts

Posted - 11/22/2012 :  14:11:29  Show Profile  Reply with Quote
Hi,

I try to build something that can show how is under how in the company.
Please find my table below

id Employee id_supirior id_team
1 Adrian 10 1
2 Tomek 1 1
3 Mirek 1 1
4 Adam 10 2
5 Ewa 4 2
6 Marta 4 2
7 Iza 10 3
8 Kamil 7 3
9 Hugh 7 3
10 Martin NUll Null Boss of the whole company

So Martin is the top boss, under Martin we have 3 managers (id=1 Adrian,id=4 Adam, id=7 Iza)under them there is rest of the team.
I expect below result:

Name count Name count Name
Martin 3 Adrian 2 Tomek
Martin 3 Adrian 2 Mirek
Martin 3 Adam 2 Ewa
Martin 3 Adam 2 Marta
Martin 3 Iza 2 Kamil
Martin 3 Iza 2 Hugh

'Count= 3' Martin is Boss for 3 person
'Count=2' Adrian and Adam and Iza is boss for 2 person.

I hope this make sense. Could you be so kind and help me?

Regards
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.11 seconds. Powered By: Snitz Forums 2000