There is a set of records in a table which are in hierarchical order. I have to get the flows separately
As per the image, the separate flows will be like,
- A -> B-> D
- A -> B-> E
- A->C-> F
- A->C-> G
but the number of levels are dynamic and no. of records per parent node can be also dynamic that means for example, B can have D, E, H,O.. so on
also these A,B,C... are not primary keys of this table
so this each record (A,B,C...) has quantity and price columns.
what I want to do is, calculate the quantity*price of each level with its previous level's quantity* price value in the separate flows. As per this example,
------------------------------
part sub_part price quantity
-----------------------------
G C 3 1
F C 1 1
E B 4 3
D B 3 1
C A 5 2
B A 2 1
final results of each flow should be,
- A -> B-> D = 6
- A -> B-> E = 24
- A->C-> F = 10
- A->C-> G = 30
no. of flows is not stable. this depends on the no. of records in hierarchy, which is dynamic
I tried with hierarchical queries but I cannot do the calculation in the same query. also tried saving the records in arrays but since they are dynamic, that didn't give expected results.