step1:使用driver_id相等条件,将order_info_tb左连接driver_tb;

step2:使用city_id相等条件,左连接city_tb;

step3:限制类型为快车,时间为9月,按city_id、日期分组统计数量即为快车订单量;

step4:按城市编号、时间排序。

select city_name, a.dt, count(distinct order_id) as flash_count

FROM order_info_tb a

LEFT JOIN driver_tb b

on a.driver_id=b.driver_id

LEFT JOIN city_tb c

on b.city_id = c.city_id

WHERE product_line_id=2 and DATE_FORMAT(a.dt, '%Y-%m')='2021-09'

GROUP BY b.city_id, a.dt

ORDER BY b.city_id, a.dt;