更新时间:2022-11-27 23:18:31
我建议使用一些东西类似于:
I'd suggest to use something similar to this:
SELECT Question, TypeOfEvaluation, [1018], [1049], [1012], [1080], [1082]
FROM (
SELECT staffid as [staffid], Question, 'self' As TypeOfEvaluation, Self_Evaluation As [Efficiency]
FROM @temptable
UNION ALL
SELECT staffid as [staffid], Question, 'mngmt' AS As TypeOfEvaluation, Management_Evaluation As [Efficiency]
FROM @temptable
) AS DT
PIVOT (SUM([Efficiency]) FOR [staffid] IN ([1018], [1049], [1012], [1080], [1082]))AS temp1
以上查询应返回:
Above query should return:
Question | TypeOfEvaluation | 1082 | 1049 |
q1? | self | 9 | 8 |
q1? | mngmt | 10 | 5 |