I Have a table in the below format.This is a self referential table where each record points to its parent record.
NODE_ID PARENT_ID COUNT
1 0 NULL
2 1 NULL
3 2 10
4 2 12
5 0 NULL
6 5 NULL
7 6 NULL
8 7 12
I want the output to be in below format.The count of parent should be the sum of count of leaf childs. Note: Only the leaf childs will contain the count. I want to roll it up till parents.
NODE_ID PARENT_ID COUNT
1 0 22
2 1 22
3 2 10
4 2 12
5 0 12
6 5 12
7 6 12
8 7 12
Please help.