Increment rows on the basis of CASE expression
I am trying to calculate a cumulative column, which would increment only on a combination of equality of 2 columns, I have written using case expression as below:
select *,
CASE WHEN CarID = lag_CarID AND Checkpoint = lag_Checkpoint THEN
"Cumulative" = "Cumulative" + 1
ELSE "Cumulative" = "Cumulative" +0
END
FROM (query for table where Cumulative has been initialized as a column with value = 0)
Result: Case expression is populating as true and false, but all values for the column Cumulative is coming 0. Please help. Below is my desired output. Apologies for earlier badly written question.
