题解 | #店铺901国庆期间的7日动销率和滞销率#

店铺901国庆期间的7日动销率和滞销率

https://www.nowcoder.com/practice/e7837f66e8fb4b45b694d24ea61f0dc9


select too.dt_123 dt, 
       round(count(distinct tod.product_id)/avg(cnt),3) sale_rate, 
       (1- round(count(distinct tod.product_id)/avg(cnt),3)) unsale_rate
from (select date(event_time) dt_123
      from tb_order_overall) too
left join (select order_id, date(event_time) dt
           from tb_order_overall) too_2
on datediff(too.dt_123, too_2.dt) between 0 and 6
left join (select order_id, product_id 
      from tb_order_detail 
      where product_id in (select product_id 
                           from tb_product_info 
                           where shop_id = 901)) tod 
using(order_id)
join (select count(product_id) cnt 
      from tb_product_info 
      group by shop_id 
      having shop_id = 901) tpi
where too.dt_123 between '2021-10-01' and '2021-10-03'
group by too.dt_123
order by dt

全部评论

相关推荐

04-19 10:50
门头沟学院 Java
想奋斗的小山竹在改简...:学院本能过简历筛选吗,我怎么看一些一本都过不了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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