Hi,
I have cursor similar as following:
Location INo Qty SourceType CPU Date
LocA AW01 10 Purchases 10.00 01/01/2004
LocA AW01 05 Transfer Out ????? 01/01/2004
LocB AW01 05 Transfer In ????? 01/01/2004
From the cursor above, I need to calculate the weighted average cost. The CPU of Transfer Out for LocA Item AW01 is unknown because it depend on previous record. In this example, it will be 10.00.
The CPU of Transfer In for LocB Item AW01 is will be 10.00 (should be same as transfer out).
In the example above, it is ok. However, my program unable to know who is the ROOT location. For example above, LocA is root location, however that could be situation that LocA has parent too.
Since, CPU of transfer in for locB always depened on the CPU of transfer out LocA, and CPU of TransferOut for LocA depend on CPU of purchases (or may be CPU of transfer In from other location).
My question is, how to do this? It look like recursive, but.. I am not sure how to implement it.
Summary, I want to calculate CPU, but the CPU of this transaction may depend on transaction of other location, which could be in several level deep.
How to write SQL to do so?
Thank you
I am not the most powerful man in this world.
I am not the worst man in this world either.
I just as same as all of you.
I still need to learn from my mistakes...