I currently have a table that shows the data I need in the format of
SELECT * FROM XYZ;
Date | Brand | Game1| Game2 | Game3 |
2017 | xxxxx | xxxxxx | ---------- | -----------|
2017 | xxxxx | ----------| yyyyyyy | -----------|
2017 | xxxxx | ----------| -----------| yyyyyyy |
The way I would like the data presented is with 4 columns in total, like this:
Date | Brand | GameName | Value
2017 | xxxxx | Game1 | 1234567.89
2017 | xxxxx | Game2 | 98.7654321
2017 | xxxxx | Game3 | 12345987.65
The reason for doing this is so that the data becomes easier to filter through to find specific values.
I've tried most other suggestions on SO but haven't had much success yet
(Such as group_concat
).
One suggestion that did work was doing Union all, however I need a dynamic query as the table will continue to be added to in the future.
Currently I'm trying to set up a cursor to do it.