I have attached a sample file of my table along with the data. I require and output which is marked in yellow columns.
I am also attaching the SQL view and a cte which i have used to derive the output. I am gettting the desired output for a single year (April-March) but when there are multiple years the output goes haywhere.
Also can i use the cte in the view to get the output.