答案 0 :(得分:1)
你可以像这样使用条件聚合:
SELECT t.Form,t.Sequence,
MAX(CASE WHEN t.question_id = 101 then t.Answer end) as First_Name,
MAX(CASE WHEN t.question_id = 101 then t.Answer end) as Last_Name,
MAX(CASE WHEN t.question_id = 101 then t.Answer end) as Age
FROM YourTable t
GROUP BY t.Form,t.Sequence