select sum(t1.订单量) as 订单量from(select from_unixtime(o.created , '%Y-%m-%d')as 日期,left(from_unixtime(o.created , '%m-%d'),2) as 月份,o.province as 省份,o.city as 城市,count(o.city)as 订单量 from `order` o join shop sh on o.shop_id=sh.id where 1=1 /*and o.status=99 订单完成*/ and pay_status=2 /*支付成功*/ and o.created between UNIX_TIMESTAMP('${MONTHDELTA(tstart1,-1)}') and UNIX_TIMESTAMP('${MONTHDELTA(tend1,-1)}')+86400 group by 日期,月份,省份,城市)t1 group by t1.月份,t1.省份,t1.城市 order by 订单量 desc