我有一个看起来像(Oracle 11.2.0.2.0)的表:
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.
谢谢您的帮助