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

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

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

select dt,round(num1/num2,3) sale_rate,round((num2-num1)/num2,3) unsale_rate
from(
select distinct date(event_time) dt,
(select count(distinct tod.product_id) 
from tb_order_detail tod
join tb_order_overall too on tod.order_id = too.order_id
join tb_product_info tpi on tpi.product_id = tod.product_id
where shop_id = '901'
and timestampdiff(day,event_time,t2.event_time) between 0 and 6) num1,  //我就想不明白为啥这里日期比较必须引用t2.date而不能用dt别名呢????????
(select count(product_id)
from tb_product_info
where shop_id = '901'
) num2
from tb_order_overall t2
where date(event_time) between '2021-10-01' and '2021-10-03') as t1

来人救救我-----------------------------------------

全部评论

相关推荐

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

创作者周榜

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