'MySql Pivot - Navada Chart Style

I have two tables in a MySql database.

enter image description here

enter image description here

I would like the query to pivot and return the data in a Nevada chart format - like this:

enter image description here

As the returns grows month to month, the return columns will increase (dynamic number of columns)

I have spent countless hours researching online for examples and everything I found does not produce the output I need.

I'm thinking it's not easy to achieve this in MySQL.

If anyone knows how to write a query to accomplish this and can share an example would be greatly appreciated.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source