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

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

全部评论

相关推荐

11-03 14:57
西北大学 营销
Belltrix:其实就是每根转动一定的角度
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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