How to convert rows values into column in sql server 2005

后端 未结 2 1909
暖寄归人
暖寄归人 2021-01-16 16:47

How to convert row into column.I have following result set.

UserID  VendorName  QuestionText AnswerText
1         KK         abc1         ans1
1         KK           


        
相关标签:
2条回答
  • 2021-01-16 17:23
    SELECT UserID, VendorName, [abc1], [abc2], [abc3]
    FROM Questions
    PIVOT (MAX(AnswerText)
        FOR QuestionText IN ([abc1], [abc2], [abc3])
    ) AS pvt
    
    0 讨论(0)
  • 2021-01-16 17:27
    SELECT grsid,contactid, [1] rejectcode, [12] rejectcode, [89] rejectcode
    FROM **rjct1**
    PIVOT (MAX(rejectcode)
        FOR rejectcode IN ([1] , [12], [89])
    ) AS pvt
    
    0 讨论(0)
提交回复
热议问题