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

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

全部评论

相关推荐

点赞 评论 收藏
分享
那一天的Java_J...:他本来公司就是做这个的,不就是正常的游戏客户端和服务器开发,软硬件联动,有啥恶心不恶心的,提前告诉你就是怕你接受不了,接受不了就没必要再往后走流程浪费时间,虽然这公司是一坨。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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