Attached is my T-SQL query. Also, attached are its results.
My focus, primarily, is on the YRACCUMDEP field. I need for this field to be a "cumulative sum" of the DEPEXP4YR field. For each YR field, YRACCUMDEP needs to sum its amount for DEPEXP4YR plus the amount of DEPEXP4YR from previous YR's.
For example, where YR = "2017", YRACCUMDEP needs to display the sum of 142.86, 130.96, and 166.66.
I don't know that I want this constructed as a CTE. I say that because, once I get my YRACCUMDEP field to where it suits my needs, I'm going to want the YRNBV field to subtract the COSTBASIS field and the YRACCUMDEP field for each YR.
Thanks! Please let me know, if there are any questions.