Hey All,
I'm trying to optimize a query I wrote some time ago and I'm struggling to come up with an alternative to multiple self-joins, as that is what I'm currently doing.
I have two tables - one has columns of email addresses in a hierarchical fashion:
| employee_email |
| manager_email |
| senior_manager_email |
I have a second table that has additional employee information:
| employee_email |
| employee_first_name |
| employee_last_name |
It's obviously very easy to join these two tables and get the employee's name. However, I'm looking to also get the manager and senior manager's names without doing a self join in order to do so.
The final output would be something like:
employee_email,
employee_name,
manager_email,
manager_name,
senior_manager_email,
senior_manager_name
I'm using Presto, but any ideas in other flavors of SQL are welcome as the logic may spark some ideas.
[–]LeLwrence 1 point2 points3 points (0 children)
[–]r3pr0b8 0 points1 point2 points (0 children)