LarrySteele
Programmer
I'm working on a query to denormalize hierarchy.
Given an org chart that looks like this...
[tt]
Margaret
|
+----------+-------------+
| |
Mary Robert
| |
+-------+-------+ Michael
| |
Laura Nancy
|
Ted
[/tt]
And stored in a table that might look like this:
[tt]
EMP MGR
Laura Mary
Mary Margaret
Michael Robert
Nancy Mary
Robert Margaret
Ted Nancy
[/tt]
I'm looking for a result set like this:
[tt]
EMP MGR_LVL_1 MGR_LVL_2 MGR_LVL_3
Laura Margaret Mary
Mary Margaret
Michael Margaret Robert
Nancy Margaret Mary
Robert Margaret
Ted Margaret Mary Nancy
[/tt]
While I'm really storing employee numbers, not names, the structure is the same. Basically, I'm looking to have the full management hierarchy for each employee per row.
I know this isn't rocket science, but I haven't been able to find the solution despite searching for hierarchies here, other forums, and my best friend, Google.
What's the best method for assembling this hierarchy?
Thanks in advance,
Larry
Given an org chart that looks like this...
[tt]
Margaret
|
+----------+-------------+
| |
Mary Robert
| |
+-------+-------+ Michael
| |
Laura Nancy
|
Ted
[/tt]
And stored in a table that might look like this:
[tt]
EMP MGR
Laura Mary
Mary Margaret
Michael Robert
Nancy Mary
Robert Margaret
Ted Nancy
[/tt]
I'm looking for a result set like this:
[tt]
EMP MGR_LVL_1 MGR_LVL_2 MGR_LVL_3
Laura Margaret Mary
Mary Margaret
Michael Margaret Robert
Nancy Margaret Mary
Robert Margaret
Ted Margaret Mary Nancy
[/tt]
While I'm really storing employee numbers, not names, the structure is the same. Basically, I'm looking to have the full management hierarchy for each employee per row.
I know this isn't rocket science, but I haven't been able to find the solution despite searching for hierarchies here, other forums, and my best friend, Google.
What's the best method for assembling this hierarchy?
Thanks in advance,
Larry