I have a table which currently looks a bit like this-
CASEID ¦ FORMNAME ¦ NAME ¦ VALUE
601554 ¦ CASEFORM ¦ Mond ¦ AAAA
601554 ¦ CASEFORM ¦ Tues ¦ BBBB
601554 ¦ CASEFORM ¦ Wedn ¦ CCCC
601554 ¦ CASEFORM ¦ Thur ¦ DDDD
I now want to create a new table in SQL that will copy the data and change the format of it entirely as follows-
CASEID ¦ FORMNAME ¦ Mond ¦ Tues ¦ Wedn ¦ Thur
601554 ¦ CASEFORM ¦ AAAA ¦ BBBB ¦ CCCC ¦ DDDD
The original table has about 400 lines, so the new table is going to need 400 columns.
My SQL knowledge is certainly limited, but I can always blunder my way to a solution when I need one. In this case however I don’t even know where to begin. Can someone point me in the right direction?
Start with this query:
and then copy the results and run them.
Then run this query:
and then copy the results and run them.
Edit: Added automated version: