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

每个商品的销售总额

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

SELECT
    p.name as product_name,
    sum(o.quantity) as total_sales,
    row_number() over(partition by p.category order by sum(o.quantity) DESC,p.product_id ASC) as category_rank
from products as p
inner join orders as o
on p.product_id=o.product_id
group by p.product_id

全部评论

相关推荐

叁六玖:你看,最后不是让你加油,就是鼓励你,还祝福你求职顺利。
点赞 评论 收藏
分享
评论
点赞
收藏
分享

创作者周榜

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