题解 | #每个商品的销售总额#

每个商品的销售总额

https://www.nowcoder.com/practice/6d796e885ee44a9cb599f47b16a02ea4

# select  product_name,total_sales,
# row_number() over(partition by category order by total_sales desc) category_rank
# from (
# select name product_name,category
# ,sum(quantity) total_sales
# from products a
# join orders b
# on a.product_id=b.product_id
# group by product_name,category
# order by category,total_sales desc
# )c

select  a.name product_name,sum(quantity) total_sales,
row_number() over(partition by category order by category, sum(quantity) desc) category_rank
from products a
join orders b
on a.product_id=b.product_id
where quantity is not null
group by a.product_id

全部评论

相关推荐

12-15 11:27
门头沟学院 Java
哇哇的菜鸡oc:所有人不要理会,就好了,后面他就知道怎么回事了,只能说有的时候市场都是被宰的人搞坏的
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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