我正在寻找SQL脚本代码(HANA)来获取输入“以下格式提供的EMPLoyee表,并给我所需的输出表。
.query()
期望的输出:从顶部到底部遍历员工层次结构
Input Table EMP_MGR_HOD: All employees with their immediate supervisors and HODs
EMPLID EMP_NAME IMMEDIATE_SUPERVISOR_NAME Dept_Head**
101 JOHN JACK Dept head 1
102 ANIL JACOB Dept head 1
103 CHRIS Mike Dept head 1
104 JACK JOE Dept head 1
105 JACOB JOE Dept head 1
106 JOE JIM Dept head 1
107 JIM Jolly Dept head 1
108 JOLLY Dept head 1 Dept head 1
109 Dept head 1 CEO Dept head 1
110 Dept head 2 CEO Dept head 2
我尝试使用以下代码来跟踪EMPLoyee层次结构,从最低级别到更高级别的主管级别。但现在我想要将EMPLoyee层次结构级别从TOP(Dept head level)遍历到BOTTOM(EMPLoyee级别)。
DeptHead_L1 L2_Sup L3_Sup L4_Sup L5..L6… LOW_LEVELEMP “EMPL”_ID**
Dept head 1 JOLLY JIM JOE JACK JOHN 101
Dept head 1 JOLLY JIM JOE JACOB ANIL 102
Dept head 1 Mike CHRIS 103
Dept head 1 JOLLY JIM JOE JACK 104
Dept head 1 JOLLY JIM JOE JACOB 105
Dept head 1 JOLLY JIM JOE 106
Dept head 1 JOLLY JIM 107
Dept head 1 Depthead 1 JOLLY 108
Dept head 1 CEO Depthead 1 109
Dept head 2 CEO Depthead 2 110
上面提到的脚本将在3个级别(L2,L3,L4)自下而上工作,我们正试图获得部门负责人和员工之间的所有级别(自上而下) 请帮助我使用SQL脚本HANA代码来实现上述所需的输出。