I am calculating cumulative by summing some columns. The code is working. But I want to include an extra variable for the first line only. Then it miscalculates. What I want to do in line 1: What I want to do except line 1: When I do this with case, the wrong result is obtained. SQL code: So for example