题解 | #店铺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

全部评论

相关推荐

测试糕手手:社会第一课,随便吹牛逼,直接说四个月,别老实。老实人只会被欺负
点赞 评论 收藏
分享
05-12 17:00
门头沟学院 Java
king122:你的项目描述至少要分点呀,要实习的话,你的描述可以使用什么技术,实现了什么难点,达成了哪些数字指标,这个数字指标尽量是真实的,这样面试应该会多很多,就这样自己包装一下,包装不好可以找我,我有几个大厂最近做过的实习项目也可以包装一下
点赞 评论 收藏
分享
程序员小白条:你是沟通了900个,不是投了900份简历,你能投900份,意味着对面都要回复你900次,你早就找到实习了,没亮点就是这样的,别局限地区,时间投的也要早,现在都要7月了
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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