I'm trying to figure out if it's possible to transform table rows to columns where the number of rows included changes at the time of the query. Here's a sample of what I'm trying to do:
Characteristics Table
strategy | year | month | aaa | aa | a |
---|---|---|---|---|---|
InvestmentA | 2020 | 12 | 5 | 4 | 10 |
InvestmentB | 2020 | 12 | 8 | 15 | 25 |
Investment(n) | 2020 | 12 | x | x | x |
Output
year | month | Credit Type | InvestmentA | InvestmentA | Investment(n) |
---|---|---|---|---|---|
2020 | 12 | aaa | 5 | 8 | x |
2020 | 12 | aa | 4 | 15 | x |
2020 | 12 | a | 10 | 25 | x |