With the sql below I get the error my datatypes are not equal. C1 is varchar and C2 is a number. I found out pivot tables must be of the same datatype, but how would I convert the number into a varachar while using case statements such as below?
SELECT userID,
CASE columnname
WHEN 'c1' THEN
'Column1'
WHEN 'c2' THEN
'Column2'
END AS
columnname,
CASE columnname
WHEN 'c1' THEN
'1'
WHEN 'c2' THEN
'2'
END AS
"Extra info",
columnresult
FROM mytable unpivot( columnresult FOR columnname IN(c1,c2)) u