select
DATE_FORMAT(p.create_Time,'%Y年%m月%d日') as time,
sum( case when plan_type_cde=1 then 1 else 0 end ) as '物资设备总需求计划',
sum( case when plan_type_cde=2 then 1 else 0 end ) as '物资设备年度需求计划',
sum( case when plan_type_cde=3 then 1 else 0 end ) as '批次招标采购需求计划',
sum( case when plan_type_cde=4 then 1 else 0 end ) as '季度分月需求计划',
sum( case when plan_type_cde=5 then 1 else 0 end ) as '需求调整计划'
from gt_demand_supply_plan p
WHERE
p.deleted=0 and p.create_Time BETWEEN '2016-10-01' and '2016-10-25'
GROUP BY time
ORDER BY time
;
结果:
<
日期 | 物资设备总需求计划 | 物资设备年度需求计划 | 批次招标采购需求计划 | 季度分月需求计划 | 需求调整计划 |
2016年10月9日 | 0 | 4 | 4 | 0 | 0 |
2016年10月10日 | 0 | 6 | 4 | 0 | 0 |
2016年10月11日 | 1 | 2 | 4 | 0 | 0 |
2016年10月12日 | 5 | 10 | 10 | 0 | 0 |
2016年10月13日 | 2 | 4 | 13 | 0 | 0 |
2016年10月14日 | 0 | 2 | 3 | 0 | 0 |
2016年10月17日 | 0 | 1 | 0 | 0 | 0 |
2016年10月18日 | 1 | 5 | 6 | 0 | 0 |
2016年10月19日 | 8 | 10 | 7 | 0 | 0 |
2016年10月20日 | 2 | 6 | 9 | 17 | 1 |
2016年10月21日 | 0 | 6 | 0 | 1 | 2 |
2016年10月24日 | 4 | 4 | 10 | 7 | 0 |