|
A |
B |
1 |
=connect("db") |
/Connect to database |
2 |
=A1.query("select * from Organization") |
/Query organization table |
3 |
>A2.switch(PARENT_ID,A2:ID) |
/The foreign key Parent_ID is mapped to the record where the ID is located to realize self join |
4 |
=A2.select@1(ORG_NAME=="Beijing Branch Office") |
/Select the record of Beijing Branch |
5 |
=A2.new(ID,ORG_NAME,~.prior(PARENT_ID,A4) :PARENT) |
/Create a new table consisting of ID, department name, and parent. The parent is obtained by recursively searching the records under Beijing branch through prior function. |
6 |
=A5.select(PARENT!=null) |
/Select the members whose parent exists, otherwise they are not subordinates of Beijing Branch. |
7 |
=A6.run(PARENT=PARENT.(PARENT_ID.ORG_NAME).concat@c()) |
/concatenate all the parent names in the parent field, separated by commas. |