I have a mysql database with this structur:
Name | 2019 | 2020 | 2021 | 2022 | ... |
---|---|---|---|---|---|
Name1 | 124 | 98 | 34.5 | NULL | |
Name2 | 102 | NULL | 34 | NULL | |
Name3 | 34 | 56 | 97 | 123 | |
Name4 | NULL | NULL | 34.5 | NULL | |
... | ... |
Every year comes new lines and a column is added.
I want to transpose this table to the structur:
Year | Name1 | Name2 | Name3 | Name4 | ... |
---|---|---|---|---|---|
2019 | 124 | 102 | 34 | NULL | ... |
2020 | 98 | NULL | 56 | NULL | ... |
2021 | 34.5 | 34 | 97 | 34.5 | ... |
2022 | NULL | NULL | 123 | NULL | ... |
... | ... |
The number of columns and rows are dynamic.
There are many threads with a similar problem (partially transpose with pivot). But I found no solution for this problem.
Thanks for help.