表参见图片1
图片2是我现在的查询结果,但是我希望得到的结果是每个member_id的数据都在一行。希望各位会sql能帮我看看怎么改一下。十分感谢
解决方法是
SELECT t.member_id,group_concat(t.01),group_concat(t.02),group_concat(t.03),group_concat(t.04),group_concat(t.05),group_concat(t.06),group_concat(t.07),group_concat(t.08),group_concat(t.09)
from
(select member_id,
case schedule_date when '2015-11-01' then group_concat(project_id) end as '01',
case schedule_date when '2015-11-02' then group_concat(project_id) end as '02',
case schedule_date when '2015-11-03' then group_concat(project_id) end as '03',
case schedule_date when '2015-11-04' then group_concat(project_id) end as '04',
case schedule_date when '2015-11-05' then group_concat(project_id) end as '05',
case schedule_date when '2015-11-06' then group_concat(project_id) end as '06',
case schedule_date when '2015-11-07' then group_concat(project_id) end as '07',
case schedule_date when '2015-11-08' then group_concat(project_id) end as '08',
case schedule_date when '2015-11-09' then group_concat(project_id) end as '09'
from bsddsys.schedule_data
group by member_id,schedule_date) t
group by member_id
版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。