Skip to content
Advertisement

Recursive query compute parent values

I have 2 tables Persons and Sales. In Person there is relation between child and parent, I want to compute 20 percent of parent values with the following condition

Persons

Sales

I want to get result like this

I wrote this query but it does not give appropriate result

Advertisement

Answer

This should be a two steps algorithm. First traverse the hierachy to get max level. Then apply the level in a reverse order.

db<>fiddle

User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement