题解|7. 9月各城市每天快车流水数据

9月各城市每天快车流水数据

明确题意:

统计2021年9月各城市的快车流水数据

问题拆解:

  • 关联订单表和司机表,得到每个订单中司机的城市ID。知识点:join
  • 关联城市表,得到每个司机的城市名。知识点:join
  • 筛选订单时间为9月且产品线类型为快车的记录。知识点:where
  • 统计各城市的快车流水。知识点:按城市分组group by;统计流水count
  • 按示例对结果排序

代码实现:

select city_name, order_info_tb.dt as dt, sum(account)
from order_info_tb
join driver_tb using(driver_id)
join city_tb using(city_id)
where product_line_id=2 and order_info_tb.dt >= "2021-09-01" and order_info_tb.dt <= "2021-09-30"
group by city_name, dt
order by dt
全部评论

相关推荐

09-13 17:25
亲切的00后在笔试:我也遇到了,所以我早他一步查看图片
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

更多
牛客网
牛客网在线编程
牛客网题解
牛客企业服务