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

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

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

with date_list as(
  select
    distinct date(event_time) dt,
    DATE_ADD(date(event_time), INTERVAL -6 DAY) dt_7d_before
  from
    tb_order_overall
  where
    event_time between '2021-10-01 00:00:00' and '2021-10-03 23:59:59'
),huopin_info as(
    select shop_id,count(distinct product_id) shangpin_num
    from
    tb_product_info
    where shop_id=901
    group by shop_id
),
info as(
  select
    a.order_id,
    a.product_id,
    date(event_time) event_dt,
    shop_id
  from
    tb_order_detail a
    left join tb_order_overall b on a.order_id = b.order_id
    left join tb_product_info c on a.product_id = c.product_id
  where
    shop_id = 901
)
select a.dt,case when xs is null then 0.000 else xs end,case when xs is null then 1.000 else 1-xs end
from date_list a
left join
(select dt,round(count(distinct product_id)/min(shangpin_num),3) xs
from(
select
  *,
  CASE
    WHEN event_dt between dt_7d_before and dt then 1
  end if_count
from
  date_list join info)t1
  left join huopin_info on huopin_info.shop_id = t1.shop_id
  where if_count=1
  group by 1)t2
  on a.dt=t2.dt
  order by 1

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-01 17:13
想去,但是听说加班强度实在难崩,所以拒绝了,现在有点心梗对面hr感觉也是实习生,打电话的时候怪紧张的,但是感觉人很好嘞
水中水之下水道的鼠鼠:哥们这不先去体验一下,不行再跑呗,大不了混个实习经历(有更好的转正offer就当我没说)
点赞 评论 收藏
分享
废物一个0offer:认真的吗二本本科找人工智能岗位
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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