MySQL将多个输出放在一行中
我正在使用以下代码:MySQL将多个输出放在一行中,mysql,Mysql,我正在使用以下代码: select case when a.questionid = 184 then a.text end 'Assistant Name', a.questionid 'Question ID', case when (a.questionid = 125 and a.optionid = 1309) or (a.questionid = 135 and a.optionid = 1298) then 'Yes' else '' end 'Labelling Mentio
select case when a.questionid = 184 then a.text end 'Assistant Name',
a.questionid 'Question ID',
case when (a.questionid = 125 and a.optionid = 1309) or (a.questionid = 135 and a.optionid = 1298) then 'Yes' else '' end 'Labelling Mentioned',
s.outletid 'Outlet ID',
s.visittime 'Visit Time'
from answer a inner join answerset s on s.id = a.answersetid
where s.VisitTime between '2014-03-01 00:00:00' and '2014-03-31 23:59:59'
and a.questionid in (125,135,184);
产生如下输出:
Assistant Name Question ID Option ID Labelling Mentioned Outlet ID Visit Time
NULL 135 203 307 03/03/2014 09:37
Alf 184 NULL 307 03/03/2014 09:37
NULL 125 107 26888 03/03/2014 09:42
NULL 125 162 26888 03/03/2014 09:42
NULL 125 1309 Yes 26888 03/03/2014 09:42
NULL 135 204 26888 03/03/2014 09:42
NULL 135 1298 Yes 26888 03/03/2014 09:42
NULL 135 167 26888 03/03/2014 09:42
NULL 135 203 26888 03/03/2014 09:42
NULL 135 204 26888 03/03/2014 09:42
NULL 135 1298 Yes 26888 03/03/2014 09:42
NULL 135 204 26888 03/03/2014 09:42
NULL 135 1298 Yes 26888 03/03/2014 09:42
NULL 135 167 26888 03/03/2014 09:42
NULL 135 129 26888 03/03/2014 09:42
NULL 135 173 26888 03/03/2014 09:42
NULL 135 204 26888 03/03/2014 09:42
NULL 135 1298 Yes 26888 03/03/2014 09:42
Steve 184 NULL 26888 03/03/2014 09:42
NULL 125 107 297 03/03/2014 09:46
NULL 125 198 297 03/03/2014 09:46
我的问题是,我需要为给定的出口生成一行输出。所需输出为“助理姓名、提及的标签、门店ID、就诊时间”,并给出助理姓名,如果任何“提及的标签”选项包含“是”,则为“是”
有没有办法做到这一点?我尝试了一些方法(分组、合并),但似乎遇到了麻烦
非常感谢 试试看。要获得更具体的答案,您需要发布相关的表模式和/或a.Thank-将提供一个旋转。