题解 | #某宝店铺动销率与售罄率#

某宝店铺动销率与售罄率

https://www.nowcoder.com/practice/715dd44c994f45cb871afa98f1b77538

select style_id, 
round(sum(sales_num)/(max(a)-sum(sales_num))*100,2), 
round(sum(sales_price)/max(b)*100,2)
from sales_tb left join 
  (select *, 
    sum(inventory)over(partition by style_id) a,
    sum(tag_price*inventory)over(partition by style_id) b
  from product_tb) as tb1
using(item_id)
group by style_id
order by style_id

#思路:
#①在表连接之前,把每种style的备货数量、备货金额用窗口函数算出来;
#②表连接,根据style_id分组,计算即可。

全部评论

相关推荐

今天 10:45
已编辑
门头沟学院 Java
昨天面美团,jvm,juc问的好深啊,感觉小林coding不太够喔,牛油们有没有什么推荐的八股网站嘛🕒 岗位/面试时间👥 面试题目🤔 面试感受11.20更新初试已过,一直泡池子啊
明天不下雨了:小林Coding:https://xiaolincoding.com/ 全栈哥:https://www.pdai.tech/ Guide哥:https://javaguide.cn/ 秀哥:https://interviewguide.cn/ 沉默王二:https://javabetter.cn/home.html 磊哥:https://www.javacn.site/interview/basic/ 小傅哥:https://bugstack.cn/ 源码哥:https://doocs.github.io/source-code-hunter/#/ 各大厂的公众号技术文章和一些经典的书籍
面试太紧张了怎么办?
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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