我有一个表,其中包含会话和问题的数字字段。每节课都有问题 1、2 和 3。1 = “努力”,2 = “满意度”,3 = “知识”。有 5 个可能的答案“非常满意”、“非常满意”、“有点满意”、“不满意”、“非常不满意”。
该表如下所示:
Session Question Answer
------- -------- ------------------
1 1 Unsatisfied
1 2 Very Satisfied
1 3 Somewhat Satisfied
我希望报告看起来像这样:
Session Effort Knowledge Satisfaction
------- -------------- -------------- --------------
1 Unsatisfied Unsatisfied Very Satisfied
2 Very Satisfied Very Satisfied Very Satisfied
但是,当我使用我的案例陈述时,我得到:
Session Question Effort Knowledge Satisfaction
------- -------- ----------- -------------- ------------
1 1 Unsatisfied NULL NULL
1 2 NULL Very Satisfied NULL
1 3 NULL NULL Unsatisfied
我正在使用的查询是:
select
distinct session
,Question
,case
when Question = '1'
then Answer
end as "Effort"
,case
when Question = '3'
then Answer
end as "Knowledge"
,case
when Question ='2'
then Answer
end as "Satisfaction"
from Survey_Table
关于如何让数据在每个会话中以单行形式返回的任何想法?