我有一個表,看起來像(11.2.0.2.0甲骨文):如何在Oracle
ParentID ID AllowsEntry
NULL A188 N
A188 1881 Y
NULL A189 N
A189 1891 Y
1891 189A Y
業務規則允許非葉級元素有數據錄入,但我需要提出報告,如果他們沒有我需要能夠查詢產生類似的輸出數據庫:
ParentID ID
NULL A188
A188 1881
NULL A189
A189 1891_
1891_ 189A
所以基本上我需要按下中間的分支,讓數據輸入到葉級。新葉需要捲起重命名分支:
Old Tree New Tree
A188 A188 -- remains the same, no data entry at this level
1881 1881 -- remains the same, data entry allowed at leaf
A189 A189 -- remains the same, no data entry at this level
1891 1891_ -- this is the level that is wrong
189A 1891 -- 1891 is push down into a new 1891_ level
189A -- and rolls up into the new level.
189B -- etc.
感謝您的幫助
哪裏'189B'從何而來? – 2013-02-27 13:58:37
父級分支級別和最低級別級別都有更多值。這是一個簡單的例子。 – tayknight 2013-02-27 16:47:49
您的示例在第一個查詢和最後一個查詢之間不一致。很難理解你現在的期望。 – 2013-02-27 17:03:55