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

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

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

select *
from(
select '2021-10-01' as "dt", round(count(1)/(
                select count(1)  # 截止到10-01,在售商品数
                from tb_product_info
                where date(release_time) <= '2021-10-01'
                and shop_id = 901
                ),3) as "sale_rate", (1-round(count(1)/( 
                select count(1)  # 截止到10-01,在售商品数
                from tb_product_info
                where date(release_time) <= '2021-10-01'
                and shop_id = 901
                ),3)) as "unsale_rate"
from(
select count(1),tod.product_id
from tb_order_overall too join tb_order_detail tod
on too.order_id = tod.order_id
join tb_product_info tpi
on tod.product_id = tpi.product_id
where event_time between '2021-09-25' and '2021-10-02'
and status = 1
and total_cnt > 0
and tpi.shop_id = 901
group by tod.product_id
)t1
union all
select '2021-10-02' as "dt", round(count(1)/(
                select count(1)  # 截止到10-01,在售商品数
                from tb_product_info
                where date(release_time) <= '2021-10-02'
                and shop_id = 901
                ),3) as "sale_rate", (1-round(count(1)/( 
                select count(1)  # 截止到10-01,在售商品数
                from tb_product_info
                where date(release_time) <= '2021-10-02'
                and shop_id = 901
                ),3)) as "unsale_rate"
from(
select count(1),tod.product_id
from tb_order_overall too join tb_order_detail tod
on too.order_id = tod.order_id
join tb_product_info tpi
on tod.product_id = tpi.product_id
where event_time between '2021-09-26' and '2021-10-03'
and status = 1
and total_cnt > 0
and tpi.shop_id = 901
group by tod.product_id
)t2
union all
select '2021-10-03' as "dt", round(count(1)/(
                select count(1)  # 截止到10-01,在售商品数
                from tb_product_info
                where date(release_time) <= '2021-10-03'
                and shop_id = 901
                ),3) as "sale_rate", (1-round(count(1)/( 
                select count(1)  # 截止到10-01,在售商品数
                from tb_product_info
                where date(release_time) <= '2021-10-03'
                and shop_id = 901
                ),3)) as "unsale_rate"
from(
select count(1),tod.product_id
from tb_order_overall too join tb_order_detail tod
on too.order_id = tod.order_id
join tb_product_info tpi
on tod.product_id = tpi.product_id
where event_time between '2021-09-27' and '2021-10-04'
and status = 1
and total_cnt > 0
and tpi.shop_id = 901
group by tod.product_id
)t3
)final_t
where dt in (
    select date(event_time)
    from tb_order_overall
)
order by dt 


# select count(1), tod.product_id
# from tb_order_overall too join tb_order_detail tod
# on too.order_id = tod.order_id
# join tb_product_info tpi
# on tod.product_id = tpi.product_id
# where event_time between '2021-09-26' and '2021-10-04'
# and status = 1
# and total_cnt > 0
# and tpi.shop_id = 901
# group by tod.product_id

全部评论

相关推荐

不愿透露姓名的神秘牛友
08-20 19:41
那一天的Java_J...:简历完全流水账,学生思维很严重,还有很大的优化空间,可以多看看牛客的简历。
点赞 评论 收藏
分享
08-24 14:45
河南大学 Java
如图所示,我在大二升大三的暑假拿到了美团的日常实习,这一路走来很不容易,所以想分享一下经验,也算是传承,因为一路走来帮助我的人也有很多。第一😇(学习路线),看黑马的视频只是一个入门,我是一直看完了springcloud。第二😇(项目),项目的话没有好坏,只有新奇与陈旧,新的项目用的人少的往往能达到让面试官眼前一亮的效果,所以没有固定的推荐,但是大家可以努力去多做几个项目,这样技术你都学会了,之后可以根据新的项目进行改造。第三😇(八股文),这个真就是跟着网站上背就行了&nbsp;一定要自己整理一套自己的八股笔记,有自己的思考与理解,我理解之后即使几个月不看也能顺滑的说出来。第四😇(面试注意),面试的时候要体现自己的思考,如果你能说出来一整个问题的逻辑那很好,但是不要着急,先说百分之八十,后百分之二十说是自己思考出来的。第五😇(当你所有的都融会贯通),八股项目相结合,八股与八股相串联,问到你一个简单的问题可以扩展延伸让面试官措不及防,被你控制,这样面试官能够问你不会的问题的概率也会大大下降。等待与努力的过程是无比的焦虑与忐忑,当字节三面挂与快手二面挂的时候我已经开始摆烂了,因为双非的机会真的不多,都没把握到,最后还是美团收留了我,任何人的路径都是不可复制的,任何人的经历也是独一无二的,不要受别人影响,加油做自己。接受大家积极发问,也可以私信我哦。
永泽one:美团官网投的嘛佬,根本约面不了
大厂面试问八股多还是项目...
点赞 评论 收藏
分享
评论
点赞
1
分享

创作者周榜

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