Best regards,
I am using the following function (LAG) to sum the previous row:
(LAG(INV_FINAL, 1, 0) OVER (PARTITION BY DISTRIBUIDORA ORDER BY PERIODO ASC) + LAG(INV_FINAL, 2, 0) OVER (PARTITION BY DISTRIBUIDORA ORDER BY PERIODO ASC)) + INV_FINAL AS RESULT
But it is not giving me the expected result as can you see:
The correct result should be :
I am attentive to your comments, I would be very grateful if you can help me, thank you.