I have 2 columns that correlate to supervisory hierarchy ids, the one is the parent and the other is the child. So imagine the parent would start with the CEO and then would have a child id such as the chief marketing officer or any of the CEOs direct reports. I'm trying to build out the entire sup org hierarchy based on these two columns.
Sup Org Name | superior org ID. | sup org ID
CEO | | 111
CPO | 111 | 222
CTO | 111 | 221
Engineering | 221 | 223
PM | 222 | 224
Backend Dev. | 223 | 228
My goal would be create the hierarchy across multiple columns so we can build out the whole hierarchy
Level 1. | Level 2 | Level 3 | Level 4
111 | 222 | 224
111 | 221 | 223
111 | 221 | 223 | 228
And so on.
I'd also like to see the above with the sup org name replaced for the id. Having it both ways is helpful for my data.
I've tried doing a lot of self-joins but there has to be a cleaner way...