select * from (
select mvqr.VoteQuestionId,mvqr.AnswerSolution from JY_MemberVoteQuestionRef as mvqr
where mvqr.MemberVoteId in (select MemberVoteId from JY_MemberVote where VoteId='166')
) as t
pivot (max(t.AnswerSolution) for t.VoteQuestionId
in
( [755],[762],[764],[770],[772],[754],[757],[769],[771] )) as puv
應用格式 : pivot ( 列2 for 列1 in ( 全部列名) )
注意點 1 : 列2 要 max() 或 min() 或 sum()
注意點2 : 全部列名 要 是 惟一的,不可重複 而且 要用 [] 包裹 例: [755]