Hello
I have more than one tables joined in one query
One of those tables has child and parent fields
for example
X Y
1 0
2 0
3 1
4 1
5 3
6 3
7 4
8 2
where X is child and Y is parent so as the table is represented with tree.
Now when making join each X got a Quantity Sold from another table
X Y Quantity sold
1 0 20
2 0 12
3 1 16
4 1 5
5 3 30
6 3 18
7 4 7
8 2 5
what I want to do is summing all quantities of all children under each value plus its value .and if it has no children select its value.
so as
X Y Quantity sold Quantity sum
1 0 20 96
2 0 12 17
3 1 16 64
4 1 5 12
5 3 30 30
6 3 18 18
7 4 7 7
8 2 5 5
Now I can get correct values in first level.so any ideas ?
Thanks in advance
I have more than one tables joined in one query
One of those tables has child and parent fields
for example
X Y
1 0
2 0
3 1
4 1
5 3
6 3
7 4
8 2
where X is child and Y is parent so as the table is represented with tree.
Now when making join each X got a Quantity Sold from another table
X Y Quantity sold
1 0 20
2 0 12
3 1 16
4 1 5
5 3 30
6 3 18
7 4 7
8 2 5
what I want to do is summing all quantities of all children under each value plus its value .and if it has no children select its value.
so as
X Y Quantity sold Quantity sum
1 0 20 96
2 0 12 17
3 1 16 64
4 1 5 12
5 3 30 30
6 3 18 18
7 4 7 7
8 2 5 5
Now I can get correct values in first level.so any ideas ?
Thanks in advance
Comment