'How to redistribute sum of specific months to another month via psql
I have a transactional table with year, month and amount. Now, there are months which we consider non-operating months (jan, feb, dec). However, SAP automatically divide depreciation for all 12 months. I need help, on how I can create another column that would remove values from (jan, feb, dec) then distribute them to other months, so I can add them to the other months via psql? I've tried window functions, just to sum and divide affected months, but I'm stuck on how to transfer them to other months.
year | month | amount | goal |
---|---|---|---|
2020 | 1 | 1,000.00 | |
2020 | 2 | 1,500.00 | |
2020 | 3 | 2,000.00 | 722.00 |
2020 | 4 | 2,500.00 | 722.00 |
2020 | 5 | 3,000.00 | 722.00 |
2020 | 6 | 3,500.00 | 722.00 |
2020 | 7 | 1,000.00 | 722.00 |
2020 | 8 | 1,500.00 | 722.00 |
2020 | 9 | 2,000.00 | 722.00 |
2020 | 10 | 2,500.00 | 722.00 |
2020 | 11 | 3,000.00 | 722.00 |
2020 | 12 | 3,000.00 |
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
Solution | Source |
---|