0

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
MikeMcD
  • 1
  • 1
  • 2
    Do not use images to paste data, it is so much better to paste it as text, so we can copy and paste. Thank you. https://stackoverflow.com/help/how-to-ask – Carlos Nov 04 '21 at 12:49
  • https://stackoverflow.com/questions/69838896/how-to-count-classses-in-columns/69839279#69839279 – Ali Fidanli Nov 04 '21 at 12:50
  • 2
    Does this answer your question? [SQL Server dynamic PIVOT query?](https://stackoverflow.com/questions/10404348/sql-server-dynamic-pivot-query) – Brenton Nov 04 '21 at 19:39

0 Answers0