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

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-08 13:05
点赞 评论 收藏
分享
每晚夜里独自颤抖:你cet6就cet6,cet4就cet4,你写个cet证书等是什么意思。专业技能快赶上项目行数,你做的这2个项目哪里能提现你有这么多技能呢
点赞 评论 收藏
分享
06-10 21:15
门头沟学院 Java
宁阿:好多这种没🧠的公司,他们估计都不知道毕业的人不能给安排实习岗
实习吐槽大会
点赞 评论 收藏
分享
评论
1
收藏
分享

创作者周榜

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