I have a properties
table with an ltree path and name columns. Ltree path contains ids of parent nodes, i.e. "7968.7969.7987.8000". Each tree node have reports
with some numeric value. I need to find sum of children nodes values for each node in ltree. Path in round brackets
(1) A
|
__________________________________
| | |
(1.2)B (1.3)C (1.4)D
|
|________________________
| |
(1.2.5) E (1.2.6) F
Reports
property_id | value
1 | 1
2 | 4
3 | 19
4 | 21
5 | 9
6 | 11
I need to find smth like
full_path | subtree_sum
A | 60 (1 + 4 + 19 + 21 + 9 + 11)
A.B | 24 (4 + 9 + 11)
A.C | 19 (19)
A.D | 21 (21)
A.B.E | 9 (9)
A.B.F | 11 (11)