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.
| Author |
Topic |
|
rc1138
Starting Member
35 Posts |
Posted - 2010-11-17 : 13:25:22
|
| Need help formulating a query that cycles through a table and picks out ID’s of users reporting under other usersContains an ID field and 8 columns of manager ID fields (created via hierarchy) Table Structure ID int MGR_LVL1 int MGR_LVL2 int MGR_LVL3 int MGR_LVL4 int MGR_LVL5 int MGR_LVL6 int MGR_LVL7 int MGR_LVL8 int e.g.Table A dataID 13 14 20 40MGR_LVL1 20 20 30 50MGR_LVL2 30 30 40MGR_LVL3 40 40 50MGR_LVL4 50 50 NULLMGR_LVL5 NULL NULL NULLMGR_LVL6 NULL NULL NULLMGR_LVL7 NULL NULL NULLMGR_LVL8 NULL NULL NULL* The table is oriented vertically as it does not seem to fit if I lay it out horizontally Say user with ID 20 logs in as per the above table we know that users 13 and 14 report directly under 20 Or if 40 logs in 30,20,13 and 14 should show up. Thanks again! |
|
|
Lamprey
Master Smack Fu Yak Hacker
4614 Posts |
Posted - 2010-11-17 : 13:41:00
|
| http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx |
 |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
|
|
|
|
|