2 つのテーブルを結合するクエリがあります。結果は でピボットする必要がありますQuestionID
。これは、QuestionID
が水平ではなく垂直になったためです。
これが私のクエリです
select
b.TOKEN,a.[GUBSRVY_TITLE], a.[QuestionID],b.[GURSRVQ_TEXT],(cast(isnull([GORSRVR_RESPONSE_1], 0) as int)
+ cast(isnull([GORSRVR_RESPONSE_2],0) as int) + cast(isnull([GORSRVR_RESPONSE_3],0) as int)
+ cast(isnull([GORSRVR_RESPONSE_4],0) as int) + cast(isnull([GORSRVR_RESPONSE_5],0) as int))
as RESPONSE
from [QuestionMappingNew3] a
left join [AUB_ICE_SURVEY_ANSWERS_MV] b
on a.[GUBSRVY_TITLE] = b.[GUBSRVY_TITLE]
join [AUB_ICE_SURVEY_ANSWERS_SUMMARY_MV] c
on b.[GUBSRVY_TITLE] = c.[GUBSRVY_TITLE]
where TERM = '2020'
出力は
TOKEN GUBSRVY_TITLE BlueQuestionID GURSRVQ_TEXT RESPONSE
939 201420-BUSS-350D-1-L-Bizhan Azad Q2Row1 The instructor was prepared for the class 5
939 201420-BUSS-350D-1-L-Bizhan Azad Q3Row1 The instructor was prepared for the class 5
939 201420-BUSS-350D-1-L-Bizhan Azad Q4Row1 The instructor was prepared for the class 5
私が必要とするのはQuestionID
、行にあることです。ピボットでこれを行うにはどうすればよいですか
よろしくお願いします