Lars,
The LAG function was very much useful and was able to get the desired output as I said. Thank you.
I was looking for an equivalent CE Sqlscript syntax but could not find it.. I am assuming for this kind of calculations if we could use the capabilities of parallel query execution it would be great.. correct me if I am wrong and if it doesn't make much difference in the above case.
Thanks,
Anil