Skip to content
Advertisement

Increase the value of a column

I want create a CTE or something that subtract a know value from a sum() of value.

How can I solve this, I tried to use LAG() on my CTE but it faulted when my value is negative.

This is what I tried to do:

This is the result of the query

And this is what I expect from the logic of the query but it isn’t the final result that I want:

And this is (the final results) what I expecting to get out apply a WHERE clause or something, that transform the “Rata” when my “Result” is negative. The new value of “Rata” become the difference between the last “Result” and Zero value, in this case the value of “Rata”=5 (cont=3) become 3. The difference between residue “Result” and “Rata” make the new “Result” 0.

Advertisement

Answer

Just a guess…

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement