hi,
i have this table
Emp Sum_sales Manager Child
10 0 Null 0
11 130 10 1
12 260 11 2
13 0 12 3


the number of children is not limited.

i need to calculate the comm of the employees: the result should be like that:
emp10=(sum_sales of emp 11 * child 1 perc)+(sum_sales of emp 12 * child 2 perc) + (sum_sales of emp 13 * child 3 perc)

emp11=(sum_sales of emp 12 * child 2 perc) + (sum_sales of emp 13 * child 3 perc)

emp12 = (sum_sales of emp 13 * child 3 perc)

how should i write the script to get this result ur help is really appreciated

best regards,
Roger