I am new to the world of SQL queries, I am comfortable writing basic sql queries limited to to CRUD operations. I am now working on a project where I have to write complex queries and I am seeking help on how to do it.
Scenario I have a table x
The logic I need to implement is
- The first record starts with some default value let us say 0 as StartCount.
- I need to add numbers Add1+Add2 and deduct Minus
- The result of step 2+StartCount becomes my EndCount
- The next Month StartCount is the EndCount of the previous row.
- I have to repeat step 2,3,4 for all the rows in the table.
How can I do this using SQL