I'm trying to unpivot this table but I always get an error.
Does somebody a solution for this ?
The result has to be like this, 3 columns ID / question (q) / total number of these row
I'm trying to unpivot this table but I always get an error.
Does somebody a solution for this ?
The result has to be like this, 3 columns ID / question (q) / total number of these row
You can use apply
:
select cc.q2 as id_cc, cq.*
from src.qa_data_cc cc cross apply
( values (cc.q77, 'q77'), (cc.q78, 'q78'),
(cc.q79, 'q79'), (cc.q80, 'q80'),
. . .
) cq(cols, colname);