How to amortise revenue / cost by month in SQL (ideally PostgreSQL)

59 Views Asked by At

I summarise revenue and cost comparison usually in excel. I would like to know if I can achieve the following transformation within SQL, ideally PostgreSQL:

From this table:

From this table | you see the long data

To this table: To this table | you see the wide data

Please ignore the bad formatting.

Thanks a lot for any help!

In SQL I have not had any progress yet.

In Excel, I set up the month-year column first and if the revenue/cost period falls in the range, the numbers will show under that month/year. Then i will transform to Pivot table.

0

There are 0 best solutions below