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

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

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

select dt,round(count(distinct product_id)/onsale_cnt,3) sale_rate,round((1-count(distinct product_id)/onsale_cnt),3)unsale_rate
from 
(select date(event_time) dt,count(distinct product_id) onsale_cnt  
from tb_order_overall,  tb_product_info
where release_time<=event_time
and shop_id='901'    
and date(event_time)  between '2021-10-1' and'2021-10-3'
group by dt )  l1  
left join 
(select date(event_time) dt1,t1.product_id
from tb_order_detail t1 left join tb_order_overall t2 on t1.order_id=t2.order_id
left join tb_product_info t3 on t1.product_id=t3.product_id
where shop_id='901'
) l2        
on datediff(dt,dt1) between 0 and 6
group by dt
order by dt

全部评论

相关推荐

12-27 22:49
门头沟学院 Java
点赞 评论 收藏
分享
11-05 10:55
中南大学 Java
要双修的猫头鹰:这面试官怕不是个m
我来点评面试官
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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