表参见图片1
图片2是我现在的查询结果,但是我希望得到的结果是每个member_id的数据都在一行。希望各位会sql能帮我看看怎么改一下。十分感谢
mysql数据查询横表转纵表
- 写回答
- 好问题 0 提建议
- 追加酬金
- 关注问题
- 邀请回答
-
4条回答 默认 最新
- banyibanyi 2015-11-21 02:10关注
我个人解决方法是
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不过感觉应该有更简单 效率更好的方法 希望知道的前辈能指点一下 谢谢
解决 无用评论 打赏 举报
悬赏问题
- ¥100 关于使用MATLAB中copularnd函数的问题
- ¥20 在虚拟机的pycharm上
- ¥15 jupyterthemes 设置完毕后没有效果
- ¥15 matlab图像高斯低通滤波
- ¥15 针对曲面部件的制孔路径规划,大家有什么思路吗
- ¥15 钢筋实图交点识别,机器视觉代码
- ¥15 如何在Linux系统中,但是在window系统上idea里面可以正常运行?(相关搜索:jar包)
- ¥50 400g qsfp 光模块iphy方案
- ¥15 两块ADC0804用proteus仿真时,出现异常
- ¥15 关于风控系统,如何去选择