teradata, reset when, Removed, running balance

Analytics
Highlighted
Tourist

teradata, reset when, Removed, running balance

I am going through some code. I still do not understand the below code. I do understand the second code for Removed but I do not understand the below code for Removed. Can someone please explain how this is calculating the Removed? I have seen an explanation of RESET WHEN in Teradata which I kind of understand. However, I still do not understand why this takes MAX of Removed. I would think this should take the running balance at the end of the day. I am struggling to understand this code. Some background: X.Removed is the balance at the beginning of the statement cycle. Thanks

 

 

 

Removed