Calculate the percentage of the root owned by its parents
问题 In simplified terms, I'm trying to calculate the percentage of the root of a tree owned by its parents, further up the tree. How can I do this in SQL alone? Here's my (sample) schema. Please note that though the hierarchy itself is quite simple there is an additional holding_id , which means that a single parent can "own" different parts of their child. create table hierarchy_test ( id number -- "root" ID , parent_id number -- Parent of ID , holding_id number -- The ID can be split into