SELECT ppse.SUBORDINATE_POSITION_ID child_position_id
,ppse.PARENT_POSITION_ID manger_position_id
,b.person_id
FROM per_pos_structure_elements_v ppse
,APPS.xxkpc_hr_personnel_v2_mv b
WHERE b.position_id(+) = ppse.SUBORDINATE_POSITION_ID
AND ppse.POS_STRUCTURE_VERSION_ID =64
AND ppse.PARENT_POSITION_ID=12493
輸出此查詢:SQL層次查詢
12604 12493 400
12605 12493 108
13644 12493 37897
12752 12493 18
13643 12493
13642 12493
13641 12493
SELECT ppse.SUBORDINATE_POSITION_ID child_position_id
,ppse.PARENT_POSITION_ID manger_position_id
,b.person_id
FROM per_pos_structure_elements_v ppse
,APPS.xxkpc_hr_personnel_v2_mv b
WHERE b.position_id(+) = ppse.SUBORDINATE_POSITION_ID
AND ppse.POS_STRUCTURE_VERSION_ID =64
AND ppse.PARENT_POSITION_ID=12504
12514 12504 449
12483 12504 450
12487 12504 456
12497 12504 156
12889 12504 168
12493 12504
12493是第一個查詢父母是孩子的第2個查詢,所以我需要刪除具有空爲person_id(第三列)中的所有行&沒有父對於孩子的在第二查詢堂妹,他是孩子的在第一個查詢,但在第一次查詢
@marc_s Oracle DB 11g – 2012-07-29 08:05:49