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

select
    a.name product_name,
    a.total_sales,
    rank() over (
        partition by
            a.category
        order by
            total_sales desc
    ) category_rank
from
    (
        select
            name,
            category,
            sum(quantity) total_sales
        from
            test.products pr
            join test.orders ord on pr.product_id = ord.product_id
        group by
            name,
            category
    ) a

全部评论

相关推荐

不愿透露姓名的神秘牛友
07-10 11:33
点赞 评论 收藏
分享
点赞 评论 收藏
分享
废物一个0offer:认真的吗二本本科找人工智能岗位
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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