Table looks like below. For Ex. row 3, Id_task = 3, level_task=3 menas it is at level 3, id_fathertask = 2 that means, its parent is the one which has id_task=2, that is the one in the second row and so on. Aim is to calculate the value of the root that is Task 1. The value of Task 1 should be 25 after calculations.
It is kind of project plan and differnt level and sub level inside. id_task is kind of a primary key.
id_task id_fathertask level_task duracion_task percent_task name_task
1 1 1 76 NULL Task 1
2 1 2 60 NULL Task 1.1
3 2 3 2 100 Task 1.1.1
4 2 3 38 NULL Task 1.1.2
5 4 4 10 100 Task 1.1.2.1
6 4 4 22 20 Task 1.1.2.2
7 4 4 5 35 Task 1.1.2.3
8 4 4 1 40 Task 1.1.2.4
9 2 3 20 NULL Task 1.1.3
10 9 4 20 20 Task 1.1.3.1
11 1 2 9 NULL Task 1.2
12 11 3 2 0 Task 1.2.1
13 11 3 7 NULL Task 1.2.2
14 13 4 2 50 Task 1.2.2.1
15 13 4 5 50 Task 1.2.2.2
16 1 2 10 0 Task 1.3
17 1 2 20 0 Task 1.4
18 1 2 6 NULL Task 1.5
19 18 3 6 NULL Task 1.5.1
20 19 4 6 NULL Task 1.5.1.1
21 20 5 6 10 Task 1.5.1.1.1