I have the following tables
Lead
- id varchar
- employee_id varchar
Employee
- id varchar
- lead_id varchar
There will be a group of employees assigned to a lead. The Lead table holds the employee id of the lead. The employee table will have lead_id which will be the id key of the leader.
The table will also contain employees which are not assigned to any lead
I need a query which will display the hierarchical result which will list the leaders and the employees under the leader
leader1 (employee )
- employee1
- employee 2
Leader 2(employee)
- employee 3
- employee 4
Any idea how this kind of hierarchical result can be obtained by a db2 query?