求个mysql查询语句问题,把2个select语句合并成一个,结果集如图所示

image.png

select count(*) as '总订单',date_format(plan_start_date,'%m') as month from ppc_produce_plan group by month 

select count(*) as '完成订单数量',date_format(actual_end_date,'%m') as month from ppc_produce_plan where  status=40 group by month;


FineReport 用户67195424 发布于 2021-1-29 18:00
1min目标场景问卷 立即参与
回答问题
悬赏:3 F币 + 添加悬赏
提示:增加悬赏、完善问题、追问等操作,可使您的问题被置顶,并向所有关注者发送通知
共1回答
最佳回答
0
ycswyw1123Lv6初级互助
发布于2021-1-29 18:03(编辑于 2021-1-29 18:06)

select ifnull(a.month,b.month) as month,a.总订单,b.完成订单数量 from  (select count(*) as '总订单',date_format(plan_start_date,'%m') as month from ppc_produce_plan group by month ) a,(select count(*) as '完成订单数量',date_format(actual_end_date,'%m') as month from ppc_produce_plan where  status=40 group by month) b where  a.month=b.month

  • 2关注人数
  • 289浏览人数
  • 最后回答于:2021-1-29 18:06
    请选择关闭问题的原因
    确定 取消
    返回顶部