I have a situation where I need to select a previous row's UPDATED value to be used in calculating the current row's value... and then that is used to calculate the next row's value, so on, and so on...
I am using the LAG function successfully- however, no matter how I write my query it seems to only pull ALL the previous values FIRST, then update each row after that separately. I need it to:
update the current value
move to the next row, grab the previous row's value (from step 1)
update the current row's value using the value from the previous row
I have tried the entire formula all within a single statement, select queries in sub-queries, joins, sub-joins, etc.
Anyone have any advice on how to perform this? Is this a stored procedure of sorts?
Thank you!
02-02-2021 07:07 AM