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

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

全部评论

相关推荐

点赞 评论 收藏
分享
09-22 15:45
门头沟学院 Java
谁给娃offer我给...:我也遇到了,我说只要我通过面试我就去,实际上我根本就不会去😁
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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